how to achieve overlay result as shown

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
gadgetkarepro
Posts: 1
Joined: 2018-05-27T06:54:01-07:00
Authentication code: 1152

how to achieve overlay result as shown

Post by gadgetkarepro »

hello guys,

i have 2 images, 1st a png file with transparency and second image jpg .
i wish to put png file over jpg file and achieve the desired output

here are the files

top

www.thesalestore.in/top.png

bottom

www.thesalestore.in/bottom.jpg

output expected

www.thesalestore.in/out.jpg


please help me out guys

i can achieve this result in photoshop

also on website - https://www.imgonline.com.ua/eng/impose ... icture.php



thanks
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: how to achieve overlay result as shown

Post by Bonzo »

The first thing you need to do is make a black and white mask the outside shape of the phone and with cutouts for the top T shape and bottom rectangular part.

You then need to use the mask to cut out the bottom image and then place the modified bottom image over the top image. You may need to do something to maintain the edge shadow/gradiant.

I suggest you create your mask and then come back with the mask, details of your Imagemagick version and operating system.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: how to achieve overlay result as shown

Post by snibgo »

A simple composite does most of what you want:

Code: Select all

magick bottom.jpg top.png -composite out.png
But this doesn't make the background outside the phone transparent. There are some ways of doing that, if you want, but they are complex to handle the anti-aliasing.
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: how to achieve overlay result as shown

Post by GeeMack »

gadgetkarepro wrote: 2018-05-27T07:23:51-07:00i have 2 images, 1st a png file with transparency and second image jpg .
i wish to put png file over jpg file and achieve the desired output
Since the overlay "top.png" already has the transparency you need, and both images are the same dimensions, snibgo's suggestion of a simple composite from the command line should do what you want.

Code: Select all

convert bottom.jpg top.png -composite out.jpg
That reads in the Dumbo image "bottom.jpg", then the cell phone image "top.png" with its existing transparent center area, and places the "top.png" over the "bottom.jpg". The bottom image shows through the transparent area of the top, and the result is exactly like your example "out.jpg".

If you're using IM7, use "magick" instead of "convert". If you want to adjust the quality of the output JPG you can set that with "-quality N", where N is 100 or less, just before the name of the output image.
Post Reply