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
BMP3 exporter ignores desired image depth when lower image depth is possible #7028
Comments
On my Mac using: magick white.png -depth 8 +dither -colors 256 BMP3:white.bmp I get a bilevel 1-bit result
What are you expecting? Perhaps your "file" program has limitation. Using Exiftool also shows 1-bit image
|
Exactly, despite depth being set to 8, the resulting image is 1 bpp. Interestingly, adding +matte will "upgrade" the file to 24 bpp. That sounds like a bug in exporter to me. |
I believe Imagemagick will generally reduce the depth to the number of actual colors in the image. Add -type truecolor gives 8-bit depth but only actually 1-bit in terms of colors.
|
That is a shame, the last thing I want is to write my own BMP encoder:( I tried to use Netscape palette for the images, so it would have 200+ colours in the palette area, but alas, the resulting image is still 1bpp or 4bpp (for palette.png). |
I am no expert. An Imagemagick developer might comment further. |
I'm not sure what output you want. A BMP with a palette? Where each palette entry contains 8-bit/channel colours? Perhaps you want 256 entries in the palette, even though the image has only one colour. I don't think IM can do that. |
Correct, I want a paletted image in 4bpp or 8bpp format, even when the image in its current state needs less colors. I believe depth parameter is the one that should specify the depth of the resulting image, but it doesn't affect the outcome. I want to note that paletted BMP that doesn't use all the palette colors is a totally valid use-case for BMP. |
What colors would you want in the palette to fill it up? |
The ones from the palette.png are a must for my use case. Having an empty BMP with web-safe colors in the palette is also not a bad idea. Having #000000 or #ffffff as filler colours is also fine. Imagine that the source image has 17 colours; IM will export it as 8bpp palletted BMP with 256 palette entries; where would it get the colours for the rest of the palette? |
If you have
|
This is quite interesting, thanks! Unfortunately, the tool I'm aiming for doesn't support RLE. |
I don't think there is any other way to force a 256-entry BMP palette. If you build IM yourself, you could patch coders/bmp.c, perhaps by changing:
... to:
I haven't tested this patch. |
ImageMagick version
7.1.1-3
Operating system
MacOS
Operating system, version and so on
MacOS 13.0, aarch64. ImageMagick from brew for x86_64 running through Rosetta
Description
For some rare bizarre old systems and programs, BMP images with palette must have precise image depth (4bpp or 8bpp). I was hoping to convert images to this format with ImageMagick. Unfortunately, it looks like if the source image has palette that is smaller than depth specified as a target, the ImageMagick will generate BMP file with smaller image depth than requested. This might be nice for creating smaller BMP files, but doesn't help when it comes to retrocomputing or specific applications.
Steps to Reproduce
File white.png is a pure white image. File palette.png has 16 colors.
The target is bmp3 with depth=8 and colors=256.
Expectations: PC bitmap 8bpp
Reality: PC bitmap 1bpp and 4bpp
Images
The text was updated successfully, but these errors were encountered: