Hey all,
I'm having some very weird problems when trying to convert PNGs on ImageMagick 6.8.8-8 Q16 x64 on Windows 7.
If the PNG only has grays in it, and I do an identify -verbose on it, the image shows as being Colorspace: Gray, regardless of how I've saved it in Photoshop. However, if I open this file in photoshop, it opens and correctly recognises the file as being in sRGB.
However, if I then use ImageMagick to convert the PNG to anything, even another PNG, and then open that file in Photoshop, it now opens with a Gray colorspace.
This is the case even if I use convert file1.png -type TrueColorMatte -colorspace sRGB -set colorspace sRGB file2.png, which has every way I could think of to force it to maintain an sRGB colorspace.
This is a problem because I am using IM to convert PNGs to TIFs for printing, and the print software for our printers is unable to read gray tifs for some reason.
The only workaround we have right now is to include a colored pixel in the image at opacity 1%, which then stops IM from converting the image to Gray, but we are unable to enforce that with images coming in from external sources.
Am I doing something wrong or is it a bug in IM?
PNG conversion forcing grayscale
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PNG conversion forcing grayscale
Within IM, "colorspace:Gray" is really shorthand for "colorspace sRGB but all the pixels are gray".
When IM saves all-gray pixels as png, it will create a 1-channel png, unless you specify PNG24: or PNG48: etc.
I don't know of any way to force a gray image to have 3 channels in tiff.
When IM saves all-gray pixels as png, it will create a 1-channel png, unless you specify PNG24: or PNG48: etc.
I don't know of any way to force a gray image to have 3 channels in tiff.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PNG conversion forcing grayscale
IM 6 actually has 3 channels even for grayscale. That is likely why it is labeled grayscale, so that IM knows all 3 channels are the same. IM 7 will only have one channel.
You may be able to modify the colorspace in the png or tif file using EXIFtool.
You may be able to modify the colorspace in the png or tif file using EXIFtool.
Re: PNG conversion forcing grayscale
Cool, okay - thanks guys! Converting to PNG24: converted the alpha channel to 1 bit, which broke my alpha gradients, but PNG wasn't my end goal anyway so that's okay.
I actually found that, for my purposes, convert file1.png -type TrueColorMatte file2.tif does what I need! Still weird about the PNG stuff though
I actually found that, for my purposes, convert file1.png -type TrueColorMatte file2.tif does what I need! Still weird about the PNG stuff though
Re: PNG conversion forcing grayscale
If you want to preserve full alpha, then use PNG32 instead of PNG24.Lev wrote:Cool, okay - thanks guys! Converting to PNG24: converted the alpha channel to 1 bit, which broke my alpha gradients