Page 1 of 1

Speed up convert for padding and resizing

Posted: 2015-02-14T01:17:12-07:00
by shayanrc
I'm running the following to first pad an image and then resize it to 64x64:

convert img.jpg -gravity center -background white -extent "$extent_factor"x"$extent_factor" -resize 64x64 img.jpg

Here extent_factor is the height or width of the image (whichever is larger).

Resizing each image takes ~5 seconds this way.

I have close to 35000 images which need to be converted this way. So, it looks like it's going to take close to 48 hrs.

Is there anything I can do to speed it up?

Running "imagemagick -version" gives me:

Version: ImageMagick 6.8.9-8 Q16 x86_64 2014-10-09 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC HDRI Modules OpenCL OpenMP
Delegates: bzlib cairo fontconfig freetype gslib jng jp2 jpeg lcms lqr ltdl lzma pangocairo png ps rsvg tiff webp wmf x xml zlib

Any help in speeding this up will be appreciated.

Thanks

Re: Speed up convert for padding and resizing

Posted: 2015-02-14T01:41:35-07:00
by snibgo
"-scale" is faster than "-resize", and for such small pictures I doubt you would see the difference.

Changing the size first, then using extent, likewise.

EDIT to add: Q8 may be faster than Q16, but not by much.

Re: Speed up convert for padding and resizing

Posted: 2015-02-14T06:46:17-07:00
by magick
Lightning fast:
  • convert -define jpeg:size=64x64 image.jpg -resize 64x64 -background white -extent 64x64 framed.jpg
ImageMagick 6.9.0-4, the current release, has a slight speed optimization which may shave off even more time for this command.