Converting to -colorspace gray changes color values?

Magick++ is an object-oriented C++ interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning Magick++.
Post Reply
i73
Posts: 50
Joined: 2016-08-24T11:30:27-07:00
Authentication code: 1151
Contact:

Converting to -colorspace gray changes color values?

Post by i73 »

When exporting from Photoshop grayscale png-8 it still contains color data, in order for me to get 'true grayscale' I have to run:

Code: Select all

$"{ myImagepath } -set colorspace RGB -colorspace gray { myImagepath }"
my problem is it changes the actual color data / color pallet, when IM runs on the photoshops export; as you can see from my test:

Export from Photoshop:
Image

Photoshop Export ran in Image Magic:
Image

Original image: Image


What can I do to solve this?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Contact:

Re: Converting to -colorspace gray changes color values?

Post by snibgo »

What version IM are you using? If fairly recent (since about v6.7.5), don't put "-set colorspace RGB". That says the image is linear RGB, which it probably isn't.
snibgo's IM pages: im.snibgo.com
i73
Posts: 50
Joined: 2016-08-24T11:30:27-07:00
Authentication code: 1151
Contact:

Re: Converting to -colorspace gray changes color values?

Post by i73 »

snibgo wrote: 2017-06-07T12:26:15-07:00 What version IM are you using? If fairly recent (since about v6.7.5), don't put "-set colorspace RGB". That says the image is linear RGB, which it probably isn't.
Using: Magic.net 6.8.7
Removing colorcolorspace fixed it a little but I am still getting a little bit lighter of a image, do I just have to live with it?

Thanks for the reply!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Contact:

Re: Converting to -colorspace gray changes color values?

Post by fmw42 »

How much lighter? Can you show us pictures? Photoshop may be outputting a grayscale profile or may be using dot gain, that ImageMagick does not use.
i73
Posts: 50
Joined: 2016-08-24T11:30:27-07:00
Authentication code: 1151
Contact:

Re: Converting to -colorspace gray changes color values?

Post by i73 »

No problem, can I output with dotgain?

I know these images look almost identical but when you toggle through them in Photoshop you can notice the difference. It's not a huge deal at this point but just wondering if I can get the identical output.

Photoshop output:
Image

The Image magic output:
Image

Side by side you can see the diff, it's slight but it's still there:
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Contact:

Re: Converting to -colorspace gray changes color values?

Post by snibgo »

Those images look the same to me. According to IM, they are identical.
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Contact:

Re: Converting to -colorspace gray changes color values?

Post by fmw42 »

There are two difference that I see in the meta data (from identify -verbose).

Your photoshop image is gray, but its colorspace is sRGB, while the IM version is gray with colorspace Gray. I doubt this has an affect.

But the photoshop image has rendering intent of perceptual and the IM version has rendering intent of Undefined. That might make a difference when viewing.

As user snibgo says, the data itself is identical.

Try adding -intent perceptual to your ImageMagick command and see if that helps. Check the identify -verbose data to be sure it is rendering intent of perceptual.
i73
Posts: 50
Joined: 2016-08-24T11:30:27-07:00
Authentication code: 1151
Contact:

Re: Converting to -colorspace gray changes color values?

Post by i73 »

Thanks guys, yeah they are pretty much identical, literally the smallest differences.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Contact:

Re: Converting to -colorspace gray changes color values?

Post by fmw42 »

If you do as snibgo said:

Code: Select all

compare -metric rmse photoshop.png imagemagick.png null:
0 (0)

Means that they are identical in pixel data.

But as I said above, you have two different rending intents. That causes differences when displaying for viewing. So add -intent perceptual to your IM command. See http://www.imagemagick.org/script/comma ... php#intent. You may need to add the same profile to both results to be sure that PS is not using Adobe RGB and ImageMagick using sRGB.
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests