I am having to use system commands in PHP, how would I resize the top layer to fit both height and width (even if the top layer is cropped slightly) it also needs to keep aspect ratio.
system('convert background.png overlay.php \
\( -clone 0 -alpha extract \) \
\( -clone 0 -clone 1 -compose multiply -composite \) \
-delete 0,1 +swap -alpha off -compose copy_opacity -composite overlay_result.png');
I am really new to imagemagick so any help would be grateful, kindest regards.
PHP Resize based on overlaying image
-
- Posts: 5
- Joined: 2019-09-02T06:58:09-07:00
- Authentication code: 1152
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PHP Resize based on overlaying image
When resizing one image to the size of another, if they have different aspect ratios then you have a choice of either resizing exactly or keeping the original aspect ratio. You can't do both.
Please show sample input images. ".php" is not a format known to IM.
Please show sample input images. ".php" is not a format known to IM.
snibgo's IM pages: im.snibgo.com
-
- Posts: 5
- Joined: 2019-09-02T06:58:09-07:00
- Authentication code: 1152
Re: PHP Resize based on overlaying image
Hi snibgo, sorry the format is actually PNG that is a typo. Please can you show me an example for both (exact resize, and keeping aspect ratio)? Both would be useful, I thought we could possibly resize but keeping the aspect ratio > then crop ? then overlay?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PHP Resize based on overlaying image
For exact resizing, and other options, see http://www.imagemagick.org/script/comma ... p#geometry
Yes, after resizing, one image may be cropped. Or the other could be extended. See options on http://www.imagemagick.org/script/comma ... ptions.php
Yes, after resizing, one image may be cropped. Or the other could be extended. See options on http://www.imagemagick.org/script/comma ... ptions.php
snibgo's IM pages: im.snibgo.com
-
- Posts: 5
- Joined: 2019-09-02T06:58:09-07:00
- Authentication code: 1152
Re: PHP Resize based on overlaying image
So if my small image is 500x800px and my large image is 2000x2000 I should probably use
500x800^ ?
500x800^ ?
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: PHP Resize based on overlaying image
That depends on what you want. I encourage you to try it out:
The result is 800x800 pixels.
Code: Select all
magick -size 2000x2000 xc: -resize 500x800^ info:
xc: XC 800x800 800x800+0+0 16-bit sRGB 1.844u 0:00.250
snibgo's IM pages: im.snibgo.com