possible bug JPG,PNG type=truecolor grayscale IM 6.8.8.2 Q16

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

possible bug JPG,PNG type=truecolor grayscale IM 6.8.8.2 Q16

Post by fmw42 »

This is a follow up to viewtopic.php?f=2&t=24801

IM 6.8.8.2 Q16 Mac OSX Snow Leopard

I did a test with -colorspace grayscale -type truecolor for jpg and png. It seems that Exiftool does not recognize the 3 channels.

Perhaps other format specific tools will know the difference.

Do I misunderstand what to expect or have I made an error in this?


convert rose: -colorspace gray -type truecolor rose_gray.jpg
Fred-Weinhauss-Mac-mini:desktop fred$ exiftool -s -ee -g1 -u -n -D rose_gray.jpg---- ExifTool ----
- ExifToolVersion : 8.71
---- System ----
- FileName : rose_gray.jpg
- BitsPerSample : 8
- ColorComponents : 1
---- Composite ----
- ImageSize : 70x46


convert rose: -colorspace gray -type truecolor rose_gray.png
Fred-Weinhauss-Mac-mini:desktop fred$ exiftool -s -ee -g1 -u -n -D rose_gray.png---- ExifTool ----
- ExifToolVersion : 8.71
---- System ----
- FileName : rose_gray.png
0 ImageWidth : 70
4 ImageHeight : 46
8 BitDepth : 8
9 ColorType : 0



Also for PNG, the png data from identify -verbose still shows grayscale.

png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 0
png:IHDR.color_type: 0 (Grayscale)
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: possible bug JPG,PNG type=truecolor grayscale IM 6.8.8.2

Post by glennrp »

If you must have an RGB 8-bit-per-sample PNG, then use png24:output.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: possible bug JPG,PNG type=truecolor grayscale IM 6.8.8.2

Post by fmw42 »

glennrp wrote:If you must have an RGB 8-bit-per-sample PNG, then use png24:output.png

Thanks, Glenn. That gets around it for PNG. Exiftool reports:
ColorType : 2


But magick said to report this also if jpg did not work (according to http://www.imagemagick.org/Usage/formats/#jpg_write)

Snibgo, can you report with your jpgdump tool what you get for the following:

convert rose: -colorspace gray -type truecolor rose_gray.jpg
eefi
Posts: 5
Joined: 2014-01-15T16:36:58-07:00
Authentication code: 6789

Re: possible bug JPG,PNG type=truecolor grayscale IM 6.8.8.2

Post by eefi »

I believe I've tracked this down to a change between 6.7.6-10 and 6.7.7-10. Running

Code: Select all

convert rose: -colorspace gray -type truecolor rose_gray.jpg
with 6.7.6-10 results in a file that opens in RGB mode in GIMP 2.8.6, but 6.7.7-10 outputs a file that opens in Grayscale mode.

I built my binaries in fresh Debian GNU/Linux sid chroots with only libjpeg8-dev available as an extra dependency.

Another test case for this bug can be found in this other forum thread: viewtopic.php?f=1&t=23421&start=15#p106918
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: possible bug JPG,PNG type=truecolor grayscale IM 6.8.8.2

Post by snibgo »

IM v6.8.8-0 on Windows 8.1.

Code: Select all

F:\web\im>%IM%convert rose: r.jpg

F:\web\im>dumpjpeg /ir.jpg
      Input: /i r.jpg
r.jpg: JPEG image is 70w * 46h, 3 color components, 8 bits per sample
JPEG process: Baseline
width 70, height 46

F:\web\im>%IM%convert rose: -colorspace gray r.jpg

F:\web\im>dumpjpeg /ir.jpg
      Input: /i r.jpg
r.jpg: JPEG image is 70w * 46h, 1 color components, 8 bits per sample
JPEG process: Baseline
width 70, height 46

F:\web\im>%IM%convert rose: -colorspace gray -type truecolor r.jpg

F:\web\im>dumpjpeg /ir.jpg
      Input: /i r.jpg
r.jpg: JPEG image is 70w * 46h, 1 color components, 8 bits per sample
JPEG process: Baseline
width 70, height 46
So "-type truecolor" does not work afer "-colorspace gray".

Weirdly "-type truecolor" does work afer "-monochrome":

Code: Select all

F:\web\im>%IM%convert rose: -monochrome r.jpg

F:\web\im>dumpjpeg /ir.jpg
      Input: /i r.jpg
r.jpg: JPEG image is 70w * 46h, 1 color components, 8 bits per sample
JPEG process: Baseline
width 70, height 46

F:\web\im>%IM%convert rose: -monochrome -type truecolor r.jpg

F:\web\im>dumpjpeg /ir.jpg
      Input: /i r.jpg
r.jpg: JPEG image is 70w * 46h, 3 color components, 8 bits per sample
JPEG process: Baseline
width 70, height 46
snibgo's IM pages: im.snibgo.com
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug JPG,PNG type=truecolor grayscale IM 6.8.8.2

Post by magick »

We can reproduce the problem you posted and have a patch in ImageMagick 6.8.8-3 Beta, available by sometime tomorrow. Thanks.
Post Reply