Skip to content

Instantly share code, notes, and snippets.

@innermond
Created August 8, 2019 22:12
Show Gist options
  • Save innermond/e350f58cb3ddc6933e882078874ee372 to your computer and use it in GitHub Desktop.
Save innermond/e350f58cb3ddc6933e882078874ee372 to your computer and use it in GitHub Desktop.
#!/bin/bash
rm -rf optimized/**
mkdir -p optimized/400w
convert unoptimized/*.jpg -sampling-factor 4:2:0 -strip -quality 80 -interlace JPEG -colorspace sRGB -set filename:base "%[base]" -resize 700x -sigmoidal-contrast 5,50% optimized/"%[filename:base].jpg"
convert unoptimized/*.jpg -sampling-factor 4:2:0 -strip -quality 80 -interlace JPEG -colorspace sRGB -set filename:base "%[base]" -resize 400x -sigmoidal-contrast 5,50% optimized/400w/"%[filename:base].jpg"
find ./optimized -regex '.*\.\(jpg\|png\)$' -exec bash -c 'convert "$@" -define webp:lossless=false "${@%.*}".webp' _ {} \;
if [ $1 = "andup" ]
then
cd optimized
aws s3 cp . s3://printuridigital.ro/img --cache-control 'max-age=2592000' --recursive
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment