convert sRGB/AdobeRGB syntax

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
msundell
Posts: 13
Joined: 2013-12-17T00:53:52-07:00
Authentication code: 6789

convert sRGB/AdobeRGB syntax

Post by msundell »

Hi there - Just to make sure I'm doing the right thing with ImageMagick and ICC profiles.

What's is the proper convert syntax to convert between let's say AdobeRGB and sRGB?

Example: convert an image from AdobeRGB to sRGB.

convert image_adobergb.jpg -profile "./AdobeRGB1998.icc" -profile "./sRGB_Color_Space_Profile.icm" image_srgb.jpg

In short, IM converts the image_adobergb.jpg input image to AdobeRGB using ICC "./AdobeRGB1998.icc", the actual pixels are converted IF they are not already in AdobeRGB. Second, the next profile operator converts the pixels to sRGB using ICC "./sRGB_Color_Space_Profile.icm" AND the jpg file is updated in it's EXIF data with the proper profile?

What about rendering intents when mapping of out-of-gamut colours are needed? relative, absolute?

Mikael
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert sRGB/AdobeRGB syntax

Post by snibgo »

That command should work.

If the input doesn't have an embedded profile, then the Adobe profile will be assigned (embedded), ie the pixels will be "declared" to be of that profile. Then the pixels will be converted to sRGB and that profile replace the embedded Adobe.

If the image already has a profile embedded, the first profile will convert them from the embedded profile to Adobe, and the embedded profile is replaced. The second will convert from Adobe to sRGB, and the embedded Adobe profile is replaced.

If you know the input already has Adobe embedded, the first "-profile" is redundant.

"-intent" is an option that affects "-profile", so if you want it, put it before "-profile". See http://www.imagemagick.org/script/comma ... php#intent
snibgo's IM pages: im.snibgo.com
msundell
Posts: 13
Joined: 2013-12-17T00:53:52-07:00
Authentication code: 6789

Re: convert sRGB/AdobeRGB syntax

Post by msundell »

Thanks - that's what I needed :-)
Mikael
msundell
Posts: 13
Joined: 2013-12-17T00:53:52-07:00
Authentication code: 6789

Re: convert sRGB/AdobeRGB syntax

Post by msundell »

One more thing, how does the -colorspace option affect -profile?

When doing a resize I want to convert the input image to AdobeRGB linear before doing the resize:

convert input.tif -colorspace RGB -resize 500 -colorspace sRGB output.png

What exactly happens to an AdobeRGB file if we do -colorspace RGB? Is it just about gamma or is there a real colorspace transformation going on under the hood?

Mikael
msundell
Posts: 13
Joined: 2013-12-17T00:53:52-07:00
Authentication code: 6789

Re: convert sRGB/AdobeRGB syntax

Post by msundell »

Here's a suggestion:

convert image_adobergb.jpg -intent relative -profile "./AdobeRGB1998.icc" -evaluate POW 2.2 -resize 800x800 -gamma 2.2 -profile "./sRGB_Color_Space_Profile.icm" image_srgb.jpg

I need to be able to linearize any colorspace given by a profile. Is it needed to explicitly remove the gamma in the operators gamma-resize-addgamma or is this something that's is handled internally by the resize operator if a profile is given (that includes a gamma)?

Mikael
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert sRGB/AdobeRGB syntax

Post by snibgo »

See the recent discussion viewtopic.php?f=1&t=25383

I suggest that if your image has a profile other than sRGB you shouldn't use "-colorspace".

If your image is AdobeRGB and you want to resize in linear RGB, you should do the conversion properly in both directions, via sRGB:

Code: Select all

convert input.tif -profile sRGB.icc -colorspace RGB -resize 500 -colorspace sRGB -profile AbobeRGB1988.icc output.png
If your images are ordinary photographs, you might discover that resizing in linear RGB makes practically no difference, and isn't worth the hassle. See http://im.snibgo.com/graygam.htm
snibgo's IM pages: im.snibgo.com
msundell
Posts: 13
Joined: 2013-12-17T00:53:52-07:00
Authentication code: 6789

Re: convert sRGB/AdobeRGB syntax

Post by msundell »

Thanks, sorry for the delay.

There's just one more thing about using the colorspace operator instead of the gamma operator.

Gamma for sRGB is not just 2.2, it has linear segments near zero. This make the colorspace operator more suitable for "to sRGB" conversions. What exactly is "-colorspace RGB", is it linear sRGB?

If we have a larger gamut AdobeRGB and scale it down to match the primaries of sRGB we will most likely loose colour accuracy depending on the input image. I guess something like closest point (relative intent) would be used even when the -colorspace operator is used. This is not a problem for AdobeRGB to sRGB but what about a resize operator for AdobeRGB to AdobeRGB? Then a gamma operator would be more suitable?

Guess this is a mix of different operators depending on the input colorspace, right?

Mikael
Last edited by msundell on 2014-04-28T06:59:45-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert sRGB/AdobeRGB syntax

Post by fmw42 »

I think you mean that -colorspace sRGB is not exactly -gamma 2.2. -gamma is a precise mathematical formula. -colorspace sRGB modifies the exact formula to correct certain color ranges. You are better using -colorspace sRGB rather than just -gamma. But then you are better off using -profile sRGB.icc rather than -colorspace sRGB
msundell
Posts: 13
Joined: 2013-12-17T00:53:52-07:00
Authentication code: 6789

Re: convert sRGB/AdobeRGB syntax

Post by msundell »

Sorry for the typo, yes! I've modified the reply post.
Post Reply