Page 1 of 1

How to change BMP color without changing original palette?

Posted: 2017-07-15T08:33:56-07:00
by swit
Hello,
I'm trying to use ImageMagick to switch single color that exists in BMP image original palette (#ffff00) into another color from existing pallete (#800000). Here is the code I’ve tried:

Code: Select all

magick.exe input.BMP -fill "#800000" -opaque "#ffff00" -type palette output.BMP
The problem is that ImageMagick automatically optimizes the pallete and moves colors around. This image shows the problem (input above, output below)
Image
Is there a way to preserve the original pallete (it must stay exactly the same, colors can't be deleted or moved around) and simply change the color on the image using one of the colors on the pallete? If it's not possible with ImageMagick what tool I can use to achieve this? (needs to support windows, linux, OSX and accept command line/terminal code).

Here is the input image in case someone would like to experiment:
https://www.dropbox.com/s/49170cjtorgqe ... R.BMP?dl=1

Re: How to change BMP color without changing original palette?

Posted: 2017-07-15T09:38:34-07:00
by snibgo
IM doesn't give the user control of the palette. Gimp does, somewhat, so that might do what you want. And you can drive Gimp from the command line.

Re: How to change BMP color without changing original palette?

Posted: 2017-07-15T09:50:24-07:00
by swit
Thanks, snibgo. The feature is needed for game modification installed by a player. Distributing whole gimp in a mod package would be excessive (especially for 3 operating systems) since this change is meant to be done ‘on the fly’ for hundreds of files. Distributing already converted files would be better but that would still increase package size significantly.

Any other ideas for simple tools that could do the job without messing with pallete? Thanks in advance.

Re: How to change BMP color without changing original palette?

Posted: 2017-07-15T10:50:39-07:00
by Sam.
As snibgo said, IM doesn't give you much control over the palette. With remap you can define exactly what colors to use in the palette, but IM will still probably reorder it.

Re: How to change BMP color without changing original palette?

Posted: 2017-07-15T11:05:54-07:00
by swit
Thanks Sam. I've just checked how many files will require this treatment and it's far less than I anticipated (less than 100). Considering small size of these BMPs I will do the conversion manually and include them in mod package.