0

I have a Drupal 7 site on a test machine (Windows 7/Apache/PHP 5.3), with the Commerce and Feeds modules installed, and succeded in importing a CSV of more than 400 products (images included!), which made me really happy.

Now I've got a problem: in the Commerce product settings, the maximum width & height are set to 700px and 400px, respectively. The feed importer didn't resize the product photos, so now I'm stuck with product images that are the original hi-resolution photos (all above 2000x1000 pixels)!

Is there a way to make Drupal automatically re-process all the Commerce product images (call it a bulk resize, or a batch resize...)? Or have I got to reprocess them through Photoshop or something like that, and then re-import the CSV?

I know that probably not many people have faced a similar situation... any hint is appreciated!

Edit

I'm using Views Slideshow with jQuery Galleria, which loads the original images and resizes them via img tag attributes width and height.

That is a reasonable part of the problem, because even if I use Image styles (Configuration>Media>Image styles), Galleria keeps using the original image, which slows down the browser and consumes a lot of RAM.

1

If you have access to a command line and ImageMagick, you can run convert from find.

In Unix et al

From Drupal root:

find sites/default/files/products -name '*.jpg' -execdir convert {} -resize 700x400 {}\;

(Note: this assumes all product images are in the "products" directory in sites/default/files. You DO want to make a copy of this directory with cp -r sites/default/files/products sites/default/files/products_backup before running the above in case it does something you don't want it to!)

In Windows:

  1. Download and install findutils.
  2. Download and install ImageMagick
  3. Make sure both are working on the commandline. Type "find" and hit enter. Same with "convert". If neither gives you a "command not found" error, they're installed and working.
  4. Backup your product images directory.
  5. Instead of the above command, try:

find sites\default\files\products -name '*.jpg' -execdir convert '{}' -resize 700x400 '{}' ';'

If find chokes on that path, try using backslashes. Also, make sure it's using the GNU version of find and not some other version (The lender Windows machine I'm working on right now has a find command, don't know if that's standard or something somebody else installed).

  • Thanks a lot, It worked like a charm! The last hint was especially useful: find seems to be a predefined Windows command so I had to use the full path to the find.exe executable. BTW, on my machine the command ran without quotes. Thanks again! – Paolo Stefan Aug 2 '12 at 9:23
  • Good to hear it worked! GNU Find is a great command, -execdir makes it really powerful for running batch queries on lists of files. – aendrew Aug 2 '12 at 12:28
0

I think its ok to have the images in high res. So you're able to use them in whatever format and size you need. Have a look at the Imagecache Module. This module allows you to create image styles. For each image you show on your page, you can have different media styles or presets and use them for example in views or in different view modes.

Edit: Built in in Drupal 7. Have a look in Admin -> Image Styles

  • 1
    My problem, not a negligible problem, is that I'm using Views Slideshow with Galleria, which loads the original image and resizes it via img tag attributes. Anyway I'm updating the question adding this detail. – Paolo Stefan Aug 1 '12 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.