Page 1 of 1

Composing a sRGB image with a RGB one

Posted: 2014-12-02T08:28:48-07:00
by marcospassos
Hello,

I've a layered PSD in sRGB and a RGB image. I'm using Imagick to place this image over a given PSD's layer, simulating the Photoshop's compositing effects. The problem is that the resulting image is darker than the one I see on Photoshop. After some research, I've discovered that setting the colorspace to RGB at the end of the command produces the expected result. The problem is that the image that is in RGB becomes opaque.

sRGB x RGB Result
Image

Expected result:
Image

PSD:
http://www.filedropper.com/teste3602

Image:
Image

Does anyone know how can I solve it?

Re: Composing a sRGB image with a RGB one

Posted: 2014-12-02T08:45:28-07:00
by snibgo
Please tell us what commands you used.

Please say what version of IM you used, on what platform.

Re: Composing a sRGB image with a RGB one

Posted: 2014-12-02T10:01:56-07:00
by marcospassos

Code: Select all

composite -gravity center image.png Global\ Illumination.png output_1.png
composite -compose Multiply Ambient\ Occlusion.png output_1.png output_2.png 
composite -compose LinearDodge Reflection.png output_2.png output_3.png 
I'm running ImageMagick 6.8.9-5 Q16 x86_64 2014-07-25 on OSX 10.9.5.

Used files:
http://ge.tt/4rmQ8r52/v/0?c?c

Re: Composing a sRGB image with a RGB one

Posted: 2014-12-02T10:22:07-07:00
by fmw42
This works for me on IM 6.9.0.0 Q16 Mac OSX. You just need to add an sRGB profile to the png image. It matches your "expected" results, but does not have any of the lighting, reflections, etc. I am not sure which result you want.

unix syntax:

Code: Select all

convert \( teste_3602.psd[0] -alpha off \) \
\( eATzcc3.png -profile /Users/fred/images/profiles/sRGB.icc \) \
-gravity center -geometry -5+0 compose over -composite result.png

Re: Composing a sRGB image with a RGB one

Posted: 2014-12-02T11:16:46-07:00
by snibgo
Your "expected result" doesn't show the reflection, even though this is marked as "correct color" on your first image.

I would use a single "convert" instead of multiple "composites".

IM will happily composite images that are in different colorspaces. It is better to convert them as required to the same colorspace before the composite. I make them RGB, then convert to sRGB at the end.

"-gravity center" isn't quite correct, so I shift the image slightly.

The result seems to be what you want, but with the reflection. Windows BAT syntax; adjust for your system.

Code: Select all

convert ^
  ( "mug\Global Illumination.png" -strip -set colorspace RGB ) ^
  mug\image.png -colorspace RGB ^
  -gravity Center -geometry -5+5 ^
  -compose SrcOver -composite ^
  ( "mug\Ambient Occlusion.png " -strip -set colorspace RGB ) ^
  -compose Multiply -composite ^
  ( mug\Reflection.png -strip -set colorspace RGB ) ^
  -compose LinearDodge -composite ^
  -colorspace sRGB ^
  c.png