Page 1 of 1

Sepia-Tone makes image blue

Posted: 2015-11-16T09:59:57-07:00
by msvc
If i use the sepia filter on the following image:

http://ops42.ms-visucom.de/temp/heart_test_cmyk.jpg

while using the following command:

convert heart_test_cmyk.jpg -sepia-tone 80% heart_test_cmyk_sepia.jpg

the resulting image gets a blue tone:

http://ops42.ms-visucom.de/temp/heart_t ... _sepia.jpg

Instead of the expected sepia one. This does not happen, if the image is converted to rgb before. Only some specific image content seems to bring up the bug. Many ImageMagick versions on different servers seem to behave like this. In the example above, the following was used:

Version: ImageMagick 6.7.8-7 2012-08-06 Q16 http://www.imagemagick.org

Re: Sepia-Tone makes image blue

Posted: 2015-11-16T10:36:28-07:00
by snibgo
Many of the effect filters (and colours in general) assume the input is sRGB, so you should convert to sRGB first.

Your version is very old, so you might want to upgrade sometime. But it won't affect this issue.

Re: Sepia-Tone makes image blue

Posted: 2015-11-17T00:19:38-07:00
by msvc
Thanks for your explanation! My thought always was, to convert colorspaces only if needed. In this case, we just want to print a given cmyk image - just with that sepia-tone applied. But if understand correctly, there is no other choice but converting to srgb before to get reasonable results. That is (imho) kind of sad, as i do more modifications to the image than needed. Even more, i have to check if the cmyk-image has an cymk-profile and reuse that:

1. Check / save for cmyk profile
2. Convert to srgb
4. Apply the filter
5. Convert to cmyk (using the prior saved profile)

Right? Is there no option inside ImageMagick to do this automatically for processings that need theses steps either?

Is there an overview of processing options that assume/need sRGB?

Re: Sepia-Tone makes image blue

Posted: 2015-11-17T00:52:59-07:00
by fmw42
Right? Is there no option inside ImageMagick to do this automatically for processings that need theses steps either?

Is there an overview of processing options that assume/need sRGB?

As I understand things, most of IM color modification assumes sRGB (or grayscale). CMYK needs to be converted to sRGB before most processing. But I know of no list that says which ones do not assume that.

Though not as good, you could always use

Code: Select all

convert image -strip -colorspace sRGB some processing -colorspace CMYK result
It would not hurt if the input was already sRGB, but it would always result in CMYK output.

I think you need to write a script to do your suggested processing outline as the best way to proceed.

Perhaps someone else can suggest a better approach or a list that identifies which processing is not dependent upon sRGB colorspace.

Re: Sepia-Tone makes image blue

Posted: 2015-11-17T01:13:08-07:00
by snibgo
If the colour profile is icc, you can extract it with "convert in.jpg temp.icc", then apply an sRGB profile, do your processing, and convert back to the saved profile. For example:

Code: Select all

convert heart_test_cmyk.jpg +write temp.icc -profile sRGB.icc -sepia-tone 80% -profile temp.icc r.jpg

Pretty much all IM operations assume the channels represent RGB, and low values are dark and high values are light. They still work with CMYK, but everything is reversed. For example, "-fill red colorize 100" will turn RGB images red, but turns your image cyan. (This is because "Red" is merely a synonym for 100% in the first channel and 0 in the rest.) "+level 80,100%" will reduce contrast, putting all values between 80 and 100%. For RGB, this will lighten the image, but it darkens yours.

I expect processing could be designed to apply a sepia effect to CMYK directly, without going via sRGB. You could experiment with operations like "-tint".

I don't know if you converted to JPG for convenience of downloads. As a general rule, doing any processing on JPG is bad news, as there are only 8 bits/channel/pixel, and processing quickly produces artifacts such as banding.

Re: Sepia-Tone makes image blue

Posted: 2015-11-17T09:12:14-07:00
by msvc
I still dont get why ImageMagick has no automatics for converting to sRGB and back if needed. So i will have to implement that by myself.

Thanks for your enlightening answers!

Re: Sepia-Tone makes image blue

Posted: 2015-11-17T09:28:04-07:00
by snibgo
ImageMagick needs to be told when to convert between colorspaces, and which method you want to use and, if you are using profiles, what profile and where it is located.

ImageMagick is a powerful set of tools from which you can build systems like Instagram. If you prefer a fully-automated system like Instagram, get Instagram.

Re: Sepia-Tone makes image blue

Posted: 2015-11-18T01:00:01-07:00
by msvc
You got me wrong. I was not thinking about a full "do everything automatic for me" functionality. But if in fact, many filters seem rely on srgb. It would be quite convinient (and possible, or not?!) to let ImageMagick do the neccessary conversions by itself?

Or at least, bring up a sensible warning like "Warning! The filter used produces unpredictable results in your current colorspace. Please convert to sRGB before!"

The current behaviour is a bad pitfall, IMHO.

BTW: Concerning your advice: does instagram indeed produce printable cmyks considering given icc-profiles?!

Re: Sepia-Tone makes image blue

Posted: 2015-11-18T11:48:40-07:00
by snibgo
But if in fact, many filters seem rely on srgb.
No. Many filters assume the channels represent red, green and blue, but not that the colorspace is sRGB.

Re: Sepia-Tone makes image blue

Posted: 2015-11-19T03:40:22-07:00
by msvc
I am confused:

by snibgo » 2015-11-16T18:36:28+01:00:
> Many of the effect filters (and colours in general) assume the input is sRGB, so you should convert to sRGB first.

by snibgo » 2015-11-18T19:48:40+01:00:
> No. Many filters assume the channels represent red, green and blue, but not that the colorspace is sRGB.

Which one is correct?

Re: Sepia-Tone makes image blue

Posted: 2015-11-19T05:18:54-07:00
by snibgo
Well spotted. The second is correct. The first should say "Many of the effect filters (and colours in general) assume the input is RedGreenBlue, so you should convert to RedGreenBlue first."

(I would abbreviate this to RGB, but that term is used by IM to mean a particular colorspace.)

As a general rule, if you don't know what colorspace you need, use sRGB. But other colorspaces are available.