Page 1 of 1

Trying to change colours in .gif

Posted: 2012-03-08T02:27:35-07:00
by dan1205
Hi.
I was searching for a tool that can change colours in gif in batch mode and i found imagemagick.
I tried to do so but i get an error message.

My command:

Code: Select all

find -name '*.gif' | xargs -n1 -i convert -fill "#2c3e84" -opaque "#339966" {
the tool lists all the images but does nothing except putting out an errorcode.

and here is the errorcode i get

Code: Select all

convert: missing an image filename `./Mobile_ge_1.gif' @ error/convert.c/ConvertImageCommand/2940
Anyone an idea what i'm doing wrong?

Re: Trying to change colours in .gif

Posted: 2012-03-08T22:03:05-07:00
by anthony
You want to use mogrify to change the image in place.

Code: Select all

  find -name '*.gif'  -print0  | xargs -0 mogrify -fill "#2c3e84" -opaque "#339966"
Mogrify can take a list of filenames, so no need for -n1 or -i

For convert you need a input and ouptut image

Code: Select all

  convert  input.gif -fill "#2c3e84" -opaque "#339966"  -output image.gif
or as it can write to image it read from, you can do this in xargs...

Code: Select all

 find -name '*.gif'  -print0  | xargs -0 -n1 -i@ convert @ -fill "#2c3e84" -opaque "#339966" @
The former is probably better.

If you have multiple processes (and not worried about 'openmp') you can substitute GNU 'parellel' for 'args'

WARNING: doing this is DANGERIOUS. if anything goes wrong you may loose images. See
http://www.imagemagick.org/Usage/basics/#mogrify