Page 1 of 1
Three layer image with transparency
Posted: 2017-05-07T14:43:33-07:00
by woopy
Hello.
I have tried a lot of different settings but cant find out how to do this:
Buy using this three images:
bottom.jpg
pattern.png
overlay.png
With:
Code: Select all
convert bottom.jpg -gravity center pattern.png -extent 1000x1000 -compose Over overlay.png -composite
I get:
With:
Code: Select all
composite bottom.jpg pattern.png overlay.png -compose over
I get:
With:
Code: Select all
composite -gravity center overlay.png pattern.png bottom.jpg
I get:
I have tried different settings for hours but can't find out how to do this.
Is there someone who sees what i'm doing wrong?
Thanks a lot in advance
Re: Three layer image with transparency
Posted: 2017-05-07T15:40:40-07:00
by fmw42
try this in IM 6 (replace convert with magick in IM 7)
Code: Select all
convert bottom.jpg overlay.png -compose hardlight -composite pattern.png -compose over -composite result.png
Please always provide your IM version and platform when asking questions on this forum.
Re: Three layer image with transparency
Posted: 2017-05-07T15:53:31-07:00
by woopy
I'll try that thanks! I saw hardlight earlier today, but didn't think that was needed since the overlay is an png with transparency.
I'll check the IM version, this was done in an rails app using IM, but I'm not sure which version was used.
Thanks a lot!
Re: Three layer image with transparency
Posted: 2017-05-07T16:03:04-07:00
by fmw42
Is there a question to this last image?
Re: Three layer image with transparency
Posted: 2017-05-07T16:39:51-07:00
by woopy
Haha forgot to add the question.
I haven't been able to try the code yet.
With the code you provided, will the pattern be placed between the bottom and overlay images?
The idea is that the white area of the overlay-image should cover the pattern if it's larger then the phone.
Thanks a lot for all your help!
Re: Three layer image with transparency
Posted: 2017-05-07T16:47:29-07:00
by fmw42
In the code I presented, the overlay it combined with the base image using -compose hard light. Then the pattern is placed on top using -compose over. The result looks the same as your desired result except that your result is a smaller an cropped image. All your images were the same 1000x1000 size.
Perhaps if you provide your rails code, some one might be able to figure out what the equivalent command line code is.
Re: Three layer image with transparency
Posted: 2017-05-08T01:57:13-07:00
by woopy
I'm so sorry, but I saw now that I used wrong images when I created the thread.
I would like the result to be as I have it in photoshop:
This image is used as bottom:
As pattern it should be possible to use an centered image like this:
And the top should be an image like this (to keep the camera and cover the the pattern that is outside the phone)
In photoshop/gimp what I do is center the pattern between the top and bottom layers and then merge the images.
Is it possible to do similar with IM? If so how should the code be?
Thanks in advance
Re: Three layer image with transparency
Posted: 2017-05-08T09:35:27-07:00
by fmw42
This is how I would use the images provided to achieve what you want.
Code: Select all
convert bottom.jpg pattern.png \( top.png -alpha extract -negate \) -gravity center -compose over -composite result.png
You need to extract the alpha channel from the top.png image and negate (invert) its color. Then use that as a mask to control the overlay of the patten.png image onto the bottom.jpg image.
You still have not answered my request that you always provide your IM version and platform!