Skip to content

Instantly share code, notes, and snippets.

@Prozi
Created August 18, 2016 21:11
Show Gist options
  • Save Prozi/255d24d8d849d2adcd512ac3b3626ad0 to your computer and use it in GitHub Desktop.
Save Prozi/255d24d8d849d2adcd512ac3b3626ad0 to your computer and use it in GitHub Desktop.
#!/bin/bash
# resize files downscale 50% when bigger than 800kb - run until happy or from cron
find . -size 0 -print0 | xargs -0 rm
minimumsize=800000
for i in * ; do
actualsize=$(wc -c < "$i")
echo "parsing file $i"
if [ $actualsize -ge $minimumsize ]; then
convert "$i" -resize 50% "$i"
echo "ok"
else
echo "size is $actualsize = under $minimumsize bytes"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment