Hi there
Let's say I have the following images:
- a.png
- b.png
- c.png
They're all of the same size and have an alpha channel. Now i need to combine them to one image (as layers one on top of the other) with different opacity values (a.png 0.9, b.png 0.5, c.png 0.6). The new image should be a transparent png too.
In PS I would make a new image, add three layers for the images and set the layer opacity. But with IM I didn't get the result i need. Not even after a couple of hours googling...
Here an example of what I intend to do:
Some help would be much appreciated, thx a lot!
PNGs as layers with different opacities
Re: PNGs as layers with different opacities
What version of IM are you using and what command did you try?
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PNGs as layers with different opacities
In the future, please identify your IM version and platform and provide separate images for us to test. I have not taken the time to try to separate your images, so this is untested and could be order dependent. But it looks like this should do what you want if I have the order correct.
Unix syntax:
Unix syntax:
Code: Select all
convert \
\( b.png -alpha set -channel a -evaluate set 0.5 +channel \) \
\( a.png -alpha set -channel a -evaluate set 0.9 +channel \) \
\( c.png -alpha set -channel a -evaluate set 0.6 +channel \) \
-flatten PNG32:result.png
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: PNGs as layers with different opacities
I'm using Windows 7 64, PhotoShop Elements 8.0, and "ImageMagick 6.9.3-6 Q16 x64".Kjuuze wrote:Now i need to combine them to one image (as layers one on top of the other) with different opacity values (a.png 0.9, b.png 0.5, c.png 0.6). The new image should be a transparent png too.
I made a 3 layer image in PS using your "a.png", "b.png", and "c.png". I set the "a.png" layer to 90% opaque, the "b.png" layer over it to 50% opaque, and the "c.png" layer over that to 60% opaque. I merged down the layers and saved it as a PNG image to compare.
Then I did this "convert" command with IM...
Code: Select all
convert ^
-background none ^
-compose blend ^
( -define compose:args=90 ( a.png -channel a -evaluate set 0 ) a.png -composite ) ^
( -define compose:args=50 ( b.png -channel a -evaluate set 0 ) b.png -composite ) ^
( -define compose:args=60 ( c.png -channel a -evaluate set 0 ) c.png -composite ) ^
-compose over ^
-flatten output.png
Start by setting the background color as "none".
Set the compose method to "blend".
Set the blend level at 90% opaque. Create a transparent image from the "a.png" and blend composite "a.png" over it.
Set the blend level at 50% opaque. Create a transparent image from the "b.png" and blend composite "b.png" over it.
Set the blend level at 60% opaque. Create a transparent image from the "c.png" and blend composite "c.png" over it.
Set the compose method to "over".
Flatten the three images into a single PNG named "output.png".
If you're on a *nix OS you'll probably have to escape those parentheses with a backslash "\" and replace the continued line carets "^" with a backslash "\" too. I'm not sure if it'll need a couple other syntax tweaks, but that should get pretty close.
Re: PNGs as layers with different opacities
Hi,
thx all for your replies!
With solutions provided like the one from "fmw42" i tested a lot and got everytime just a blank white output file.
Great thanks to GeeMack for his detailed solution. The result is nearly perfect the one i expected! Like he mentioned for Unix Platforms the command looks as followed:
I would have been lost without you! IM is so powerful but hard to master! Thx again for the great and fast help and have a nice day!
thx all for your replies!
I'll do so in future, thx for your hint! Platform is Unix and IM Version is 6.7.7-10.In the future, please identify your IM version and platform and provide separate images for us to test.
With solutions provided like the one from "fmw42" i tested a lot and got everytime just a blank white output file.
Great thanks to GeeMack for his detailed solution. The result is nearly perfect the one i expected! Like he mentioned for Unix Platforms the command looks as followed:
Code: Select all
convert \
-background none \
-compose blend \
\( -define compose:args=90 \( a.png -channel a -evaluate set 0 \) a.png -composite \) \
\( -define compose:args=10 \( b.png -channel a -evaluate set 0 \) b.png -composite \) \
\( -define compose:args=60 \( c.png -channel a -evaluate set 0 \) c.png -composite \) \
-compose over \
-flatten output.png
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: PNGs as layers with different opacities
try
Code: Select all
convert -background none \
\( a.png -alpha on -channel a -evaluate multiply 0.9 +channel \) \
\( b.png -alpha on -channel a -evaluate multiply 0.5 +channel \) \
\( c.png -alpha on -channel a -evaluate multiply 0.6 +channel \) \
-flatten PNG32:result1.png
Re: PNGs as layers with different opacities
Thxs for your reply again. Your solution seems to work just perfect for my case. And it's a little bit less complicated than the previous solution. Thumbs up!!