Trying to change colours in .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
dan1205
Posts: 1
Joined: 2012-03-08T01:54:52-07:00
Authentication code: 8675308

Trying to change colours in .gif

Post 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?
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Trying to change colours in .gif

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply