Skip to content

Instantly share code, notes, and snippets.

@fidepus
Created October 2, 2025 17:08
Show Gist options
  • Save fidepus/fa046299378c58867e9fbc05ec3080a7 to your computer and use it in GitHub Desktop.
Save fidepus/fa046299378c58867e9fbc05ec3080a7 to your computer and use it in GitHub Desktop.
Pretty Instagram borders
#!/usr/bin/env bash
# Usage:
# squarefit.sh input.jpg [output.jpg]
# Or batch:
# squarefit.sh *.jpg
# Needs imagemagick installed
set -euo pipefail
W=1080
H=1350
OUTDIR="IG_Exports"
# Create output folder if it doesn't exist
mkdir -p "$OUTDIR"
process_one() {
in="$1"
base="$(basename "${in%.*}")"
out="${OUTDIR}/${base}_IG.jpg"
magick \
\( "$in" -auto-orient -resize ${W}x${H}^ -gravity center -extent ${W}x${H} -blur 0x24 \) \
\( "$in" -auto-orient -resize x${H} \) \
-gravity center -compose over -composite \
-strip -colorspace sRGB -quality 92 "$out"
echo "Made: $out"
}
if [[ $# -eq 0 ]]; then
echo "Drag files onto this script or run: squarefit.sh input.jpg"
exit 1
fi
for f in "$@"; do
process_one "$f"
done
@fidepus
Copy link
Author

fidepus commented Oct 2, 2025

This will create an image and turn it into a the correct format for an Instagram feed post, using a blurred and zoomed in version of the same image as a border.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment