Grayscale too dark

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
honkifyoulikeme
Posts: 3
Joined: 2016-04-15T13:12:17-07:00
Authentication code: 1151

Grayscale too dark

Post by honkifyoulikeme »

Once again the same issue. Convering grayscale PNM to PNG makes the image dark. Apparently messed up colorspace conversion (linear vs. non linear).

All I want is the EXACT pixel values in the PNM to also be available in the PNG.

I've found

This: viewtopic.php?f=4&t=21269
and this: https://www.imagemagick.org/discourse-s ... hp?t=21275

However, no solutions proposed in those threads of work for me:

convert in.pnm -colorspace sRGB out.png
convert in.pnm -colorspace RGB -colorspace out.png

out.png is always darker.

Current shitty workaround:

convert in.pnm -gamma 2.2002200220022003 out.png

where 2.2 is 1 / 0.4545. While this is close, it doesn't give me the exact pixel values. I really, really, really, really need the EXACT values, no conversion nonsense. How can I do this? I would like to attach example files, but apparently I can't in this forum...
honkifyoulikeme
Posts: 3
Joined: 2016-04-15T13:12:17-07:00
Authentication code: 1151

Re: Grayscale too dark

Post by honkifyoulikeme »

I've uploaded a tar.gz file with all the image examples to pastebin: http://pastebin.com/tgWrnbCt

Grab it (the content between the "start" and "end" lines) and do

$ openssl base64 -d <in.txt >out.tar.gz
$ tar xfvz out.tar.gz
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Grayscale too dark

Post by fmw42 »

What version of IM and what platform? Grayscale has changed over the years from non-linear to linear and back to non-linear. See viewtopic.php?f=4&t=21269. PNM (PGM) I believe is linear gray. See http://www.imagemagick.org/script/formats.php

try

Code: Select all

convert image.pnm -set colorspace RGB -colorspace sRGB image.png
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Grayscale too dark

Post by snibgo »

honkifyoulikeme wrote:All I want is the EXACT pixel values in the PNM to also be available in the PNG. ... I really, really, really, really need the EXACT values, no conversion nonsense.
With current versions of IM, what you read is what you'll get. Are your values linear RGB or non-linear sRGB? After reading, set the colourspace accordingly: "-set colorspace sRGB" or whatever. This won't change values.
snibgo's IM pages: im.snibgo.com
Post Reply