Hi!
I'd like to convert my images to squares with the same size.
I have a white (backgroud) square on which I'd like to place the actual image. It would be great if the background rectangle could be resized to match the MAX(width or height) of the actual picture.
Meta:
resize background-pic width and height to max (width(pic1),height(pic1)
place pic1 centered on resized background-pic
output to pic1_new
Is it possible with the command line tool?
Rgds
KKL
Resize and combine
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Resize and combine
What version of IM, on what platform? I'll assume IM v7 on Windows BAT.
I've used Blue because it's easier to see than White.
Code: Select all
magick ^
in.png ^
-set option:MYSIZE %%[fx:max(w,h)]x%%[fx:max(w,h)] ^
-size %%[MYSIZE] xc:Blue ^
+swap ^
-gravity Center ^
-compose Over -composite ^
out.png
snibgo's IM pages: im.snibgo.com
Re: Resize and combine
Hi!
Thank you for your reply.
I am using Win command line (dos window)
Thank you for your reply.
I am using Win command line (dos window)
Re: Resize and combine
WAU! It Works!!
Thak you so much!!!
Thak you so much!!!
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Resize and combine
Check snibgo's suggestion for a simple way to composite your input image over a square background. Here's a way to use "-extent" to expand the background to a "max(w,h)" square and produce the same result...
Code: Select all
magick input.png -gravity center -background white -extent %[fx:max(w,h)]x%[fx:max(w,h)] result.png