How do I add a black border to every image in a folder and output the result into another folder?

55 Views Asked by At

I have a folder with 500 images, I want to add a 5% black border to all of them and then output into a new folder just to keep the originals intact but can't find online support for Mac.

The Input folder is: /Users/Luca/Desktop/Stampa/Italiane/*

The Output folder I want it to be is: /Users/Luca/Desktop/Mogrify

I've found something online but mostly for Windows and couldn't reproduce it on my Mac for some reason, I've tried various things without any results.

So I've tried tinkering with it and done:

mogrify -border 5%x5% -bordercolor Black /Users/Luca/Desktop/Stampa/Italiane/* -path /Users/Luca/Desktop/Mogrify

But it outputs nothing, just work on the images for a while, create a white border card and then deletes it.

2

There are 2 best solutions below

0
On

Actually, the answer is to use the -path operator which is provided for that very purpose, i.e. to write the output images in a different folder:

mkdir OUTPUT
magick -path OUTPUT -crop ... -border ... *.png

In the same vein, you can also set a new format (e.g. PNG) for the output files with:

magick -format PNG -crop ... -border ... *.jpg
0
On

Ok, so I wasn't using my brain, if someone else wants to do what I've asked just duplicate your folder and let Imagemagick work on the first one, so if it outputs a bad result you have it already saved. The code I used is:

mogrify -bordercolor Black -border 5%x5% /Users/Luca/Desktop/Stampa/Italiane/*