HOWTO: Square Instagram images with white borders

I noticed that a lot of Instagram users, such as Alan Schaller to name but one, were posting images with thick white borders to make their images into the square images that Instagram favours. I like the striking look these images have in the Instagram gallery.

I wondered for some time about the best way of adding this border and from brief searches there are apps that will add the border but my workflow involves Lightroom so I wanted to integrate the border making into my export process.

I work on a Mac, and already have ImageMagick installed so I knew a little shell scripting would probably go a long way.

A couple of searches later, and I found this page describing how to use ImageMagick to create a floating image within a square canvas without changing the aspect ratio of the image.

Instagram resizes to 1080px wide so by using the following code I could make a rectangular image into a square:

convert -background white -gravity center input.jpg \
     -resize 1080x1080 -extent 1080x1080 result.jpg

Here’s an example from my street photo today. See it on Instagram here.

Once I could do that, the rest was simple. I have a Lightroom export for Instagram images that resizes them and places them in a folder where they are synced automatically with my phone using Syncthing.

Export actions have a “post processing” section where Lightroom can call an external script. I created the following script, made it executable with chmod a+x add_instagram_border.sh and added to Lightroom using “Open in Other Application”.

#!/bin/sh

# Square and add white borders to images.
# https://odd.blog/

for i in "$@"
do
    /usr/local/bin/convert -background white -gravity \
        center "$i" -resize 1080x1080 -extent 1080x1080 \
        /tmp/out.jpg
    mv /tmp/out.jpg "$i"
    open "~/Sync/Instagram"
done

The script goes through the exported images from Lightroom, adding borders to them, and then at the end opens the folder in Finder for review.

Hopefully this will be useful to someone else. If you add borders to your images, how do you do it?

One thought on “HOWTO: Square Instagram images with white borders

Leave a Reply

%d bloggers like this:

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close