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:
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.
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:
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.