Total newbie to Gimp needs a bit of help....

I have 104 PNG files that I need to do one simple thing to… enlarge the canvas by 200 pixels on each of the four sides.

These are floor plans of the buildings on a campus. The person who originally scanned the blueprints used some kind of automated process that cropped the margins… and stored
them in a folder with the building number, building name, and then inside the folder there is a PNG file for each floor… example:

Directory: 172-(name)

172-8-Penthouse-(elevator equipment)

I have 40 directories with 104 files in them.

Now I an using the floorplans in a software package that needs the margins.

All I want to do is to add 200 pixels to all four sides of each floor plan file.

Does GIMP have a macro function that will do this?
Or am I destined to waste many hours manually adding the same white space margins to each file?

Thanks in advance


Hey @YetAnotherMike welcome

While gimp is an excellent program I think you should use imagemagick:

convert input.jpg -gravity center -background white -extent 200x200 output.jpg


Don’t know about Gimp, but ImageMagick will do it easily.

Haven’t tested it, but this command should work:

convert -bordercolor white -border 200 input.jpg output.jpg

If you’re on Windows, the FOR command will make it easy to loop over all the files.

Untested (!) example if you want to run it from the command line directly:

For /R C:\temp\ %G IN (*.png) do convert -bordercolor white -border 200 "%G" "border_%G"

To run it from a batch file, you need to double the %'s. So %%G instead of %G.

1 Like

You both were faster then me, as I was just trying to create a command myself.

@Donatzsky your command works.
@paperdigits your’s sadly does not - it just crops to 200x200. Which is weird because the manual on first sight says it should do that.

@YetAnotherMike if you want to run such a command on all images in a folder you can use mogrify:

mogrify -bordercolor white -border 200 *.png

Beware that this will overwrite the original files, so only use it on a copy of the files.

The FOR command I posted will recursively loop through all the folders and files, creating a copy called border_ORGFILE.png.

1 Like

If the commandline is not your friend, here is another idea.

In darktable you can use the framing tool to add a border by percentage of the image.

That won’t give you an exact margin of 200 pixels, but if you want a quick and convenient solution to add some margin to the files this can do very nicely.

…Well, using Gimp, there is a batch plugin BIMP that gives you a GUI rather than command line.

Add folders of files.
Add ‘other gimp procedure’ and the script-fu-border filter (In Gimp this is Filters → Decor → Border)
Set the destination and keep the folder structure. Looks like this:

There are options to change the export format and rename if required.
edit: Really helps if you give version of Gimp and OS (Win / linux / MacOS)

ImageMagick -extent 200x200 will set the final size of the image to those dimensions, by adding or removing pixels. See ImageMagick – Command-line Options

The required task is different; we want to add 200 pixels on each of the four sides. “-border 200x200” does that.

IM can process all the files in a directory (using “magick mogrify”), but can’t recurse into subdirectories. Use a shell facility for that.

If your IM is v7 (ie not more than a couple of years old) I suggest using magick instead of convert.

1 Like