Categories
Photography

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?

By Donncha

Donncha Ó Caoimh is a software developer at Automattic and WordPress plugin developer. He posts photos at In Photos and can also be found on Google+ and Twitter.

Leave a Reply