Post

Simplifying social media images

One challenge for small business social media that I feel acutely is that you need to meet all of the social media image guidelines. Resizing your images can be a real pain. I created a simple script for MacOS that uses ImageMagick to resize all of the images in a directory to fit for instagram (square) and twitter/facebook (rectangle). Note that the twitter and facebook sizes are not exactly the same, but this is close enough for my purposes.

Not only does it resize, but it also adds my logo to each image, on the bottom for Instagram and on the right for twitter/facebook. This makes sharing on brand a little easier.

echo "Starting InstaMagick"
theDir="${HOME}"
echo "$theDir"
FILES=$theDir/backgrounds/*
# create the temporary correct sized backgrounds
mkdir $theDir/tmp

i=0
for f in $FILES
  do
    let i++
    convert $f -filter lanczos -resize 1080x1080^ -gravity Center -crop 1080x1080+0+0 +repage \
    -gravity South  $theDir/logo.png -background transparent -extent 1080x1080\
    -layers merge  $theDir/tmp/$i.jpg
    convert $f -filter lanczos -resize 1080x540^ -gravity Center -crop 1080x540+0+0 +repage \
    -gravity Southeast  $theDir/logo.png -background transparent -extent 1080x540\
    -layers merge  $theDir/tmp/tw$i.jpg
  done
echo "I resized $i images for instagram and twitter/facebook"

This is a super simple way to resize. Once I have all of the images that I want to resize, I can just call the function. Then, the images in the tmp directory are ready for sharing.

Now to go fill my buffer

If this script helps you, please let me know.

This post is licensed under CC BY 4.0 by the author.