Hello guys,
I'm trying to insert a random width / hight pixel image into part of a fix background.
The point is , I want to add my png image into the left corner of the iMac image with max height for second image.
I mean i want to add the skull image with MAX height and dog image with MAX size into the iMac front bar.
I've attached some file that I did with photoshop. I want to make it with IM.
I would be grateful if you guys help me with this
Insert image into another Image with max size
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Insert image into another Image with max size
Post your ImageMagick version and platform and your two original images. That way we can show you how to do it with your data.
Basically pick the 4 corner coordinates of the screen in the background image and the corresponding 4 corner coordinates of the image to be overlaid. Then use +distort perspective with the 4 pairs of corresponding coordinates. Then composite one over the other.
See https://imagemagick.org/Usage/distorts/#perspective
__________________________
Please, always provide your IM version and platform when asking questions, since syntax may differ.
Also provide your exact command line and your images, if possible.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
Basically pick the 4 corner coordinates of the screen in the background image and the corresponding 4 corner coordinates of the image to be overlaid. Then use +distort perspective with the 4 pairs of corresponding coordinates. Then composite one over the other.
See https://imagemagick.org/Usage/distorts/#perspective
__________________________
Please, always provide your IM version and platform when asking questions, since syntax may differ.
Also provide your exact command line and your images, if possible.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Insert image into another Image with max size
Here are two example methods.
Image:
Background screen:
Method 1: overlay the barn image over the screen
Method 2: Make the screen are transparent and put the screen image over the barn image:
See
https://imagemagick.org/Usage/distorts/#box3d
https://imagemagick.org/Usage/layers/#merge
https://imagemagick.org/Usage/draw/#matte
https://imagemagick.org/Usage/basics/#swap
Image:
Background screen:
Method 1: overlay the barn image over the screen
Code: Select all
convert \
screen.jpeg \
\( barn.jpg \
-background none -virtual-pixel none \
+distort perspective \
"0,0 203,153 399,0 541,153 399,299 541,355 0,298 203,355" \) \
-background none -layers merge \
screen_barn.jpg
Method 2: Make the screen are transparent and put the screen image over the barn image:
Code: Select all
convert \
\( screen.jpeg \
-fuzz 20% -fill none -draw "matte 350,270 floodfill" \) \
\( barn.jpg \
-background none -virtual-pixel none \
+distort perspective \
"0,0 203,153 399,0 541,153 399,299 541,355 0,298 203,355" \) \
+swap -background none -layers merge \
screen_barn2.jpg
See
https://imagemagick.org/Usage/distorts/#box3d
https://imagemagick.org/Usage/layers/#merge
https://imagemagick.org/Usage/draw/#matte
https://imagemagick.org/Usage/basics/#swap
Re: Insert image into another Image with max size
Thanks for your answer,fmw42 wrote: ↑2019-02-23T13:25:16-07:00 Post your ImageMagick version and platform and your two original images. That way we can show you how to do it with your data.
Basically pick the 4 corner coordinates of the screen in the background image and the corresponding 4 corner coordinates of the image to be overlaid. Then use +distort perspective with the 4 pairs of corresponding coordinates. Then composite one over the other.
See https://imagemagick.org/Usage/distorts/#perspective
__________________________
Please, always provide your IM version and platform when asking questions, since syntax may differ.
Also provide your exact command line and your images, if possible.
See the top-most post in this forum "IMPORTANT: Please Read This FIRST Before Posting" at http://www.imagemagick.org/discourse-se ... f=1&t=9620
If using Imagemagick 7, then see http://imagemagick.org/script/porting.php#cli
For novices, see
http://www.imagemagick.org/discourse-se ... f=1&t=9620
http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/reference.html
http://www.imagemagick.org/Usage/
https://github.com/ImageMagick/usage-markdown
https://imagemagick.org/script/porting.php#cli
I'm using osX and IM version : ImageMagick 7.0.8-14 Q16 x86_64 2018-10-2
I used this commend for resize my 2nd image and insert on the iMac panel :
Code: Select all
convert 1.jpg "(" 2.png -resize x110 -gravity southeast ")" -gravity Center -geometry -350+216 -composite Pro.jpg
Re: Insert image into another Image with max size
Thanks again !
but i dont want to add an background into the monitor's screen.
I want to insert a png transparent file into the front panel ( left corner at apple logo ). I mean the white space panel. but my png files has different heights. I want to add them at maximum hight in front panel.
When i use the
Code: Select all
convert 1.jpg "(" 2.png -resize 110 -gravity southeast ")" -gravity Center -geometry -350+216 -composite Pro.jpg
Last edited by Optis on 2019-02-23T16:13:02-07:00, edited 1 time in total.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Insert image into another Image with max size
try adding x to 110 (x100) as per WxH without the W. When you leave it off, it tries to use either W or H whichever the aspect ratio decides is larger
See https://imagemagick.org/script/command- ... p#geometry
P.S. Best not to quote the whole previous message, especially when there are images.
Code: Select all
convert 1.jpg "(" 2.png -resize x110 -gravity southeast ")" -gravity Center -geometry -350+216 -composite Pro.jpg
P.S. Best not to quote the whole previous message, especially when there are images.
Re: Insert image into another Image with max size
Thank you dear fmw42,
now it works. <3
now it works. <3