New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
-remap reorders the palette unpredictably #6916
Comments
I suggest using After running your commands above, you can do this:
The files You can, of course, combine the commands. |
Hello, I'm trying to make the very same sort of batch processing for 70 128x128 icons, so I tried this command on one of them, and with my 13 colors palette image, output is only 4 colors:
Do you have any idea why this is the case? |
-scale averages blocks of pixels. If the output size is much smaller than the input size, you may indeed get fewer (averaged) colors. |
ImageMagick version
7.1.1-21
Operating system
Linux
Operating system, version and so on
Debian 12
Description
(I'm actually not sure what the OS version is, as I'm using a docker image)
When you use -remap to replace the colors in an image with the palette from another given image, the order of the colors in the palette is not preserved. Not only that, it's not reordered in a consistent, predictable manner, that is, if you remap several images with the same palette image as parameter to -remap, you get different resulting palettes (same colors but potentially in different orders), I guess depending on the input image.
I'm not sure if there's a criterion to the ordering, maybe from the least used to most used color or viceversa (it's certainly not just a function of the colors, otherwise it would at least be consistent, it's at least also a function of the input image, unless it's just totally utterly random). But either way, since you're being explicitly asked to use a given palette, I don't see a reason for not taking the palette as is including the order.
Steps to Reproduce
Expected behavior: the two output images should have the same palette with colors in the same order, and that should be the same as the palette in palette.png
Observed behavior: the two output images have palettes with the same colors but in different order.
Images
images.zip
The text was updated successfully, but these errors were encountered: