Skip to content

Instantly share code, notes, and snippets.

@kamalx
Created August 29, 2020 03:13
Show Gist options
  • Save kamalx/314d85e04c999b50c62a55f3d4e2ab46 to your computer and use it in GitHub Desktop.
Save kamalx/314d85e04c999b50c62a55f3d4e2ab46 to your computer and use it in GitHub Desktop.
BULK GENERATING OG IMAGES -- Zach Leatherman: https://www.zachleat.com/web/bulk-og/
# prepare images for og serving
echo "Uses imagemagick."
images="input/*.png"
watermark="watermark.png"
outputDir="output/"
bgColor="#00dc9e"
mkdir tmp/
mkdir $outputDir
convert "$watermark" -resize x60 -gravity center -background "transparent" "tmp/watermark.png"
for i in $images
do
# resize image
convert "$i" -resize x530 -background $bgColor -gravity center -extent 1200x630 "tmp/${i##*/}"
# add watermark
composite -gravity SouthEast -geometry +20+20 "tmp/watermark.png" "tmp/${i##*/}" "${outputDir}${i##*/}"
done
rm -rf tmp/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment