I have a number of PNG image files that I’d like to increase in size. I do not want to rescale the image. I just want to extend the white background further down and to the right. In GIMP terms what I want is to increase the Canvas Size, and cover the increased area with white pixels, in a batch context. The input images may be different sizes, but the output images should all be a fixed size (e.g.: 1280 x 720 pixels).
I’ve tried this with various online tools, with GIMP, and with a very old version of Photoshop. Most of the tools I’ve tried to date do one of the following which I don’t want:
- Rescale the existing image to cover the new canvas size, or
- Center the starting image and extend the canvas in all directions, or
- Fail to perform this in a batch mode.
I just want to extend existing PNG images with additional white pixels down and to the right. What’s the easiest way to do this to a large number of files?
3
Answers
The ImageMagick command that did what I needed used "convert" with the -geometry and -composite arguments. In a Windows batch file context:
imagemagick is a common tool for this. the
-crop
operation combined with-gravity
can probably do what you want.magick input.jpg -crop 1000x1000+0+0! -background white -flatten output.png
source for the magick spell: https://legacy.imagemagick.org/Usage/crop/
In ImageMagick, you process a whole folder of images using mogrify. You can extend them using -extent. With mogrify, it is wise to first create a new empty directory to hold the results. So
Where WxH, is your desired final width and height after padding with the white. This assumes that all images will be padded to the same width and height
Expand By Size
Expand By Percent
For ImageMagick 7, add magick before mogrify. So "magick mogrify …"