Page 1 of 1
Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-17T14:52:30-07:00
by cinymini
Hi,
I’m trying to replicate Photoshop’s or Gimp’s “Overlay” blend mode in IM. Here’s what I’m doing in Gimp:
1) Open any image.
2) Make it grayscale.
3) Set the layer’s blend mode to Overlay.
4) Set the layer’s transparency to 50%.
5) Set the foreground color to light red #ff9090.
6) Create a new layer behind the image layer, filled with the foreground color.
The result will be a “duotone like” image, or, rather, the light red superimposed with the grayscale image. The result is the same for the “Soft Light” blend mode in Gimp.
I was out of luck, though, trying that in my IM 6.8.9-1 Q16 x86_64 2014-06-29. Here’s what I tried
convert in.jpg -colorspace Gray \( +clone +matte -fill '#ff9090' -colorize 100% \) -compose overlay -composite out.jpg
The result is not even close. Also, I don’t see how I could replicate step 4) from above instructions. I have a feeling that the algorithm for the overlay operator differs between Photoshop/Gimp and IM.
Am I doing something wrong? Or is there any way to replicate the Gimp behavior in IM?
Edit: Here is my in.jpg, as well as the two outputs from Gimp and IM:
https://imgur.com/a/vv2RG
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-17T15:06:00-07:00
by fmw42
try
Code: Select all
convert in.jpg \
\( -clone 0 -fill "#ff9090" -colorize 100 \) \
\( -clone 0 -colorspace gray -alpha set -channel alpha -evaluate set 50% +channel \) \
-delete 0 \
-compose overlay -composite out.jpg
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-17T15:10:18-07:00
by fmw42
Alternate:
Code: Select all
convert \
\( in.jpg -colorspace gray -alpha set -channel alpha -evaluate set 50% +channel \) \
\( -clone 0 -alpha off -fill "#ff9090" -colorize 100 \) \
+swap \
-compose overlay -composite out.jpg
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-17T15:11:36-07:00
by fmw42
If those do not work, then post your input image and the output image from your PS or GIMP processing.
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-17T15:30:56-07:00
by snibgo
1. Remove "%" from "-colorize 100%". The % sign is not good syntax here. See
http://www.imagemagick.org/script/comma ... p#colorize
2. You "create a new layer
behind the image layer". So do the same in IM, eg with "+swap" before "-compose".
3. According to
https://docs.gimp.org/en/gimp-concepts- ... -bug162395, "overlay" has a bug in Gimp. It actually does what SoftLight should do and does do. So use "SoftLight" instead.
Code: Select all
convert fMcAbNx.jpg -channel A -evaluate set 50% +channel ( +clone -fill #ff9090 -colorize 100 -alpha off ) +swap -compose SoftLight -composite out.png
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-17T16:08:59-07:00
by cinymini
Thanks both for the helpful insights.
What I noticed is that -evaluate set 50% doesn’t seem to make any difference:
Code: Select all
convert fMcAbNx.jpg -channel A -evaluate set 50% +channel ( +clone -fill #ff9090 -colorize 100 -alpha off ) +swap -compose SoftLight -composite out.png
convert fMcAbNx.jpg -channel A -evaluate set 10% +channel ( +clone -fill #ff9090 -colorize 100 -alpha off ) +swap -compose SoftLight -composite out.png
convert fMcAbNx.jpg -channel A -evaluate set 90% +channel ( +clone -fill #ff9090 -colorize 100 -alpha off ) +swap -compose SoftLight -composite out.png
all give the same result. As that percentage is my step 4 from above recipe, how can I achieve that?
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-17T16:21:13-07:00
by snibgo
So it doesn't. Insert "-alpha set" after the jpeg file.
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-17T16:25:22-07:00
by cinymini
Thanks so much!
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-17T17:12:39-07:00
by snibgo
I had forgotten "make it grayscale", and that is "-colorspace gray" or some other IM operation after you have read the JPEG, so:
Code: Select all
convert fMcAbNx.jpg -colorspace Gray -alpha set -channel A -evaluate set 50% +channel ( +clone -fill #ff9090 -colorize 100 -alpha off ) +swap -compose SoftLight -composite out.png
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-18T07:55:03-07:00
by cinymini
Yes sure, already that – thanks!
This works fine on 6.8.9-1 Q16 x86_64 2014-06-29 as well as 6.9.9-11 Q16 x86_64 2017-09-22. Yet, the server is running 6.7.8-9 2016-06-16 Q16, on which I have to do -colorspace gray -colorspace rgb.
Thanks again both!
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-18T07:59:32-07:00
by cinymini
It looks like I spoke too soon. On 6.7.8, the result is different than on 6.8.9 and 6.9.9. In fact, the image is overall darker, and there’s far less contrast.
Is there anything I can do about that, given that I can’t update IM on the server?
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-18T09:35:50-07:00
by fmw42
IM 6.7.8.9 was at the time IM was undergoing changes with regard to linear and non-linear gray. And there were buggy versions as well. See
viewtopic.php?f=4&t=21269
Best if you upgrade 6.7.8.9. Using -colorspace gray -colorspace rgb was the recommended solution. You could also try -colorspace gray -colorspace srgb
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-18T17:03:46-07:00
by snibgo
cinymini wrote:On 6.7.8, the result is different ...
I strongly suggest that you don't use such an old version. If you have no choice, then don't use grayscale images with that version.
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Posted: 2017-10-18T18:10:50-07:00
by fmw42
If you are on Redhat / CentOS 7.1, you could install IM from binary into your own directory rather than using the one that came with the distro on the server (or get your hosting provider to install it for you). See
http://www.imagemagick.org/script/download.php for the RPM to do the install and instructions.