Emulate Photoshop/Gimp blend mode “Overlay”
Emulate Photoshop/Gimp blend mode “Overlay”
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
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Emulate Photoshop/Gimp blend mode “Overlay”
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Emulate Photoshop/Gimp blend mode “Overlay”
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
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Emulate Photoshop/Gimp blend mode “Overlay”
If those do not work, then post your input image and the output image from your PS or GIMP processing.
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Emulate Photoshop/Gimp blend mode “Overlay”
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.
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
snibgo's IM pages: im.snibgo.com
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Thanks both for the helpful insights.
What I noticed is that -evaluate set 50% doesn’t seem to make any difference:
all give the same result. As that percentage is my step 4 from above recipe, how can I achieve that?
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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Emulate Photoshop/Gimp blend mode “Overlay”
So it doesn't. Insert "-alpha set" after the jpeg file.
snibgo's IM pages: im.snibgo.com
Re: Emulate Photoshop/Gimp blend mode “Overlay”
Thanks so much!
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Emulate Photoshop/Gimp blend mode “Overlay”
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
snibgo's IM pages: im.snibgo.com
Re: Emulate Photoshop/Gimp blend mode “Overlay”
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!
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”
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?
Is there anything I can do about that, given that I can’t update IM on the server?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Emulate Photoshop/Gimp blend mode “Overlay”
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
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
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Emulate Photoshop/Gimp blend mode “Overlay”
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.cinymini wrote:On 6.7.8, the result is different ...
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Emulate Photoshop/Gimp blend mode “Overlay”
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.