Page 1 of 1

Speeding up replacing of colors in large files?

Posted: 2008-06-26T04:37:31-07:00
by koemer
Hello everybody. This is my first post, so cheers everyone!

The main question is bold.

I want to switch white to black and vice versa, leaving the other colors as they are.

I tried "-fill" and "+negate" and it works just fine but my problem is, that the source file is very large (464MB), so the process lasts over 15 minutes on a modern quad core machine.

A much faster way would be, just to change the colors in the color palette, but i don't know how to do this.

How can i replace a color in the color palette, so for example what was white will turn black in the picture?

Re: Speeding up replacing of colors in large files?

Posted: 2008-06-26T16:19:21-07:00
by fmw42
some approaches to changing a few colors are at: http://www.imagemagick.org/Usage/color/#replace

you may be able to use -map (or +map) to play with the color table, but I have never tried that.

Perhaps someone else can give you more advice.

Re: Speeding up replacing of colors in large files?

Posted: 2008-06-26T17:59:54-07:00
by magick
ImageMagick 6.4.2-2 Beta negates an image in parallel. On a quad-core processor you can expect upwards of a 300% speed-up for any algorithm that is parallelized.

Re: Speeding up replacing of colors in large files?

Posted: 2008-06-29T23:47:04-07:00
by koemer
Is the Beta available?

Re: Speeding up replacing of colors in large files?

Posted: 2008-06-30T04:13:17-07:00
by magick
Try the current release, 6.4.2-1.

Re: Speeding up replacing of colors in large files?

Posted: 2008-06-30T19:59:32-07:00
by anthony
negating images, global color change, and replacing individual colors can all be done easily with ImageMagick. see IM examples
http://imagemagick.org/Usage/color/

however other than specific color to color replacement, or gradient color replacement there is no "palette" color replacement functions. In fact internally IM does not really make use of 'palette' colors, until the image is actually saved. It is designed more to deal with global 'millions' of colors, than a pallette of colors.

Of course you can fudge things. Saving an image say in uncompressed XPM format for example will have a text representation of the 'palette' in the header of the image, which can then be replaced very easily with a plain text editor or othe text processing methods.