Page 1 of 1
Duplicate Photoshop Luminosity and Color blends with opacity
Posted: 2017-02-23T08:07:45-07:00
by kqwil
I've a pretty simple Photoshop document that I want te replicate using IMagick. Have been trying all day but can't figure it out. I'm not very familiar with image processing. I hope you guys can help me out.
In Photoshop I've 2 images. The bottom layer contains images 1. The second layer consists of the image 2 and the blend 'Luminosity' with an opacity of 55%. The third layer consist of image 2 again, but this time with the blend 'Color'.
Thus Layers:
[image 2 - color]
[image 2 - luminosity 55%]
[image 1]
Let me know if this is not clear.
So far I only got a composition of the two images with an opacity and a colorize. This gives a result similar to what I've in Photoshop, however this is not sufficient and I would like to duplicate my Photoshop as good as possible.
Code: Select all
$image1 = new Imagick('image1.png');
$image2 = new Imagick('image2.png');
$image1->modulateImage(100 , 0 ,100);
/*
* opacity
*/
//$image2->setImageOpacity(0.5); //Doesn't work for some reason
$opacity = new Imagick();
$opacity->newPseudoImage(
$image1->getImageHeight(),
$image1->getImageWidth(),
"canvas:gray(75%)"
);
$image2->compositeImage($opacity, Imagick::COMPOSITE_COPYOPACITY, 0, 0);
$image1->compositeImage($image2, Imagick::COMPOSITE_ATOP, 0, 0);
/*
* colorize
*/
$image2 = new Imagick('wallframe.png');
$image1->compositeImage($image2, Imagick::COMPOSITE_COLORIZE, 0, 0);
$image1->writeImage ("result.png");
Re: Duplicate Photoshop Luminosity and Color blends with opacity
Posted: 2017-02-23T08:24:07-07:00
by snibgo
So, you have two images (image 1 and image 2). You combine them once with blend mode "Luminosity", and then with "Color".
According to
http://www.simplefilter.de/en/basics/mixmods.html , these are simple modes that use HSL or similar colorspace, taking L from one image and HS from the other.
I don't have Photoshop. To help us help you, can you link to URLs of:
1) image 1
2) image 2
3) images 1 and 2 blended 100% with "Luminosity"
4) images 1 and 2 blended 100% with "Color"
Please make these fairly small (eg 200x200 pixels), not lossy compressed (so not JPEG). PNG is fine.
You can upload images to somewhere like dropbox.com and paste the URLs here.
Re: Duplicate Photoshop Luminosity and Color blends with opacity
Posted: 2017-02-23T08:44:55-07:00
by kqwil
Correct, I think the only magic Photoshop does that I can reproduce is the luminosity blend with 55% opacity. Which I guess means that it doesn't take the entire L from image 2 but combines the two in some way.
Anyways you seem to understand it better then me, so correct me if I'm wrong.
The images you suggested:
https://www.dropbox.com/s/g1bm2fpysk31w ... 1.png?dl=0
https://www.dropbox.com/s/urie05u9yws7b ... 2.png?dl=0
https://www.dropbox.com/s/dv94p955jxyvm ... y.png?dl=0
https://www.dropbox.com/s/z1nivabfg699k ... r.png?dl=0
And the result I would like to have:
https://www.dropbox.com/s/nhktukzznthck ... r.png?dl=0
Re: Duplicate Photoshop Luminosity and Color blends with opacity
Posted: 2017-02-23T09:26:13-07:00
by snibgo
The answer is as I said, but the IM colorspace isn't HSL, but HCLp. Windows BAT syntax. For bash, replace each ^ with \
Code: Select all
convert psimage2.png psimage1.png ^
-colorspace HCLp ^
-separate ^
-delete 2-4 ^
-combine ^
-set colorspace HCLp ^
x4_col.png
convert psimage1.png psimage2.png ^
-colorspace HCLp ^
-separate ^
-delete 2-4 ^
-combine ^
-set colorspace HCLp ^
x4_lum.png
x4_col.png is the same as your image_1_and_2_blended_100_color.png.
x4_lum.png is almost the same as your image_1_and_2_blended_100_luminosity.png, but the luminosity from image 2 behind the grid is shifted by one pixel. I suspect you accidentally nudged the image when you created it.
Does that solve your problem? Can you get the 55% opacity? If not, then please post the result from PS of luminosity with 55% opacity.
Re: Duplicate Photoshop Luminosity and Color blends with opacity
Posted: 2017-10-26T21:29:25-07:00
by stewartm82
Thanks for this answer it's exactly what I wanted however I'm not sure how to set the opacity for just the top layer. How would I apply this to the above script?
Re: Duplicate Photoshop Luminosity and Color blends with opacity
Posted: 2017-10-26T22:49:04-07:00
by snibgo
Which script? I didn't exactly understand what the OP meant by opacity, nor what you mean. Please explain your problem, with examples.
Please also say what version of IM you use, on what platform.
Re: Duplicate Photoshop Luminosity and Color blends with opacity
Posted: 2017-10-30T15:13:11-07:00
by stewartm82
Thanks for your reply. I'm attempting to recreate blending in the same way that photoshop's luminosity layer works. Here is an example of what I am trying to recreate.
- Screen Shot 2017-10-31 at 8.58.04 am.png (191.37 KiB) Viewed 24206 times
This image consists of two photoshop layers. The uppermost layer is set to luminosity with an opacity of 60%. The bottom layer in this case is a pink colour fill however it will be swapped out for a different image on the fly. The idea being to superimpose the top layer on to any other image using the photoshop luminosity blend to create a realistic condensation effect. The layers reset back to the normal filter with an opacity of 100% appear as follows.
- Screen Shot 2017-10-31 at 9.10.50 am.png (241.53 KiB) Viewed 24206 times
The bottom layer is just a colour fill but this will be dynamic
- Screen Shot 2017-10-31 at 9.12.04 am.png (21.18 KiB) Viewed 24206 times
The following is how the designer has setup the photoshop layers
- Screen Shot 2017-10-31 at 8.59.13 am.png (16.56 KiB) Viewed 24206 times
I was hoping to recreate this in imagemagick and I can for the most part with convert scrips that where posted above however I can't seem to recreate the opacity of the luminosity layer.
I'm using
Version: ImageMagick 7.0.7-8 Q16 x86_64
but a this point I'm flexible with the IM version as I am building my own from source.
Re: Duplicate Photoshop Luminosity and Color blends with opacity
Posted: 2017-10-30T15:22:06-07:00
by fmw42
Please post your images not screen snaps.
Using your screen snaps, compare
Without 60% luminosity
Code: Select all
convert pink.png image.png -compose luminize -composite result1.png
With 60% luminosity
Code: Select all
convert pink.png image.png \( -clone 1 -fill "gray(60%)" -colorize 100 \) -compose luminize -composite result2.png
Is that what you want? If not, then swap the two inputs and colorize or luminize
Code: Select all
convert image.png pink.png \( -clone 1 -fill "gray(60%)" -colorize 100 \) -compose colorize -composite result3.png
Code: Select all
convert image.png pink.png \( -clone 1 -fill "gray(60%)" -colorize 100 \) -compose luminize -composite result4.png
ImageMagick may be using HSL colorspace or some other colorspace when luminizing and colorizing than Photoshop. If that is the case, , which is likely, then you will need to use snibgo's method of separating channels in the desired colorspace and then recombine the appropriate combination.
Re: Duplicate Photoshop Luminosity and Color blends with opacity
Posted: 2017-10-30T15:52:04-07:00
by snibgo
I can see the images.
Windows BAT syntax.
Code: Select all
convert ^
bottleCol.png ^
bottle.png ^
-gravity Center -crop 320x370+0+0 +repage ^
-colorspace HCLp ^
-separate ^
( -clone 2,5 ^
-compose Blend -define compose:args=25 -composite ^
) ^
-delete 2-5 ^
-combine ^
-set colorspace HCLp ^
-colorspace sRGB ^
bottleBlnd.png
Explanation: I renamed your images: bottleCol is the solid-colour image. Your images are different sizes, so I have crudely cropped both to the same size. I work in HCLp space, taking H and C from the solid colour image, and L as a blend of the L from both images.
This works fine in v6.9.5-3. In v7.0.3-6 using "magick", the blending doesn't work. I suppose there was a bug which may have now been fixed.
Re: Duplicate Photoshop Luminosity and Color blends with opacity
Posted: 2017-10-30T21:23:04-07:00
by stewartm82
Perfect! Thanks so much! That's exactly what I was hoping for. I can confirm the opacity issue in 7.0.7-8 so it must not have been fixed yet.