Batch resize creates animated gif

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
btilford
Posts: 3
Joined: 2012-03-21T09:36:21-07:00
Authentication code: 8675308

Batch resize creates animated gif

Post by btilford »

I'm using the following command to resize all images in a directory to multiple sizes. If one of the images in the directory happens to be a gif the output is an animated gif. Any tips on how to prevent this? Preferably without needing to do multiple executions. Looking at the commands and flags work it seems like it would be hard to parse that an animated gif should not be created

Code: Select all

convert /somedir/*.* +clone -resize 1000x1000 -set filename:f 'resized/%t_1000.%e' -write '%[filename:f]' +delete +clone -resize 600x600 -set filename:f 'resized/%t_600.%e' -write '%[filename:f]' +delete +clone -resize 320x320 -set filename:f 'resized/%t_320.%e' -write '%[filename:f]' +delete -resize 80x80 -set filename:f 'resized/%t_80.%e' '%[filename:f]'
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch resize creates animated gif

Post by fmw42 »

you can use +adjoin to make it output to separate images. see http://www.imagemagick.org/script/comma ... php#adjoin
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Batch resize creates animated gif

Post by anthony »

First you are cloning an image without using parentesis. A sure sign you are not doing things right!

You are reading in a image, clone it, resize BOTH images, write TWO images, then delete the last image only!
Using parenthesis, you deperate the original input image from the resize and writes, and thus prevents the duplications.

The parenthesis must be space seperated from the other options (they are themselves a seperate option).

See writing an image multiple times, in IM examples...
http://www.imagemagick.org/Usage/files/#write

ASIDE: IMv7 will error on the use of clone outside parenthesis! It was never ment to be used outside parenthesis!

Also make sure the input image is NOT itself a multi-image file (GIF, ICO, MNG, etc)
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply