I have a 1-bit grayscale image that I'm trying to convert to 24-bit TrueColor png (no alpha). However imagemagick seems to always create an all-black image. Here is the command:
convert -background white -alpha off -type TrueColor -depth 8 working.png PNG24:test.png
(originally I didn't have the " -background white -alpha off" options, but that produced the same result).
Original image:
http://www.groupboard.com/working.png
Converted image:
http://www.groupboard.com/bad.png
This is with v6.7.2-7, but I also tried with the latest version and it has the same problem.
1-bit grayscale to TrueColor not working
-
- Posts: 2
- Joined: 2016-12-07T11:26:25-07:00
- Authentication code: 1151
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: 1-bit grayscale to TrueColor not working
Working.png is 8 bits, not 1 bit. All the pixels are black, with varying transparency.
PNG24: is sufficient to give it 3 channels, in v6.9.5-3.
PNG24: is sufficient to give it 3 channels, in v6.9.5-3.
snibgo's IM pages: im.snibgo.com
Re: 1-bit grayscale to TrueColor not working
Your original image isn't a one-bit grayscale image; it's a 16-bit Gray-alpha image in which the 8-bit Gray component is always black and the 8-bit alpha component carries the actual image of the text. You can make a visible image by doing
Use "convert" instead of "magick" with older versions of ImageMagick.
Code: Select all
magick working.png -background white -flatten png24:flattened.png
-
- Posts: 2
- Joined: 2016-12-07T11:26:25-07:00
- Authentication code: 1151
Re: 1-bit grayscale to TrueColor not working
Ok, thanks - that works. Some of the images I was having problems with were 1-bit grayscale, but that particular one is 8-bit.
The problem seems to be the TrueColor that is screwing things up in this particular case. Should "-type TrueColor -depth 8" not do the same thing as putting png24: on the dest image? I don't understand
The problem seems to be the TrueColor that is screwing things up in this particular case. Should "-type TrueColor -depth 8" not do the same thing as putting png24: on the dest image? I don't understand
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: 1-bit grayscale to TrueColor not working
"-type XXX" is really just a hint to file encoders (the software that writes output files). The different encoders (for PNG, TIFF, JPG etc) use these hints in slightly different ways when deciding how many channels, and how many bits/channel, to write in the file.
"PNG24:" instructs the PNG encoder to use exactly 3 channels, with exactly 8 bits in each.
"PNG24:" instructs the PNG encoder to use exactly 3 channels, with exactly 8 bits in each.
snibgo's IM pages: im.snibgo.com