How can I transform an image while maintaining its original size by cutting off some areas, and filling others (preferably with a specifiable background color), using Imagemagick on the windows command line:

Here is the basic idea.

enter image description here

Note: Please be sure the method is lossless if possible (besides the limitations of reading and writing from lossy formats).

1 Answer 1


Okay, after going through the Imagick documentation several times, I figured it out.

the page option is what I needed:

magick [input image] -page +20+20 -background black -flatten [output image]

the background can also be made transparent using the alpha option.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .