Skip to content

Instantly share code, notes, and snippets.

@andrey-yantsen
Last active August 29, 2015 14:06
Show Gist options
  • Save andrey-yantsen/19cd12a8fe6dff4a2258 to your computer and use it in GitHub Desktop.
Save andrey-yantsen/19cd12a8fe6dff4a2258 to your computer and use it in GitHub Desktop.
#!/bin/bash
for i in $(ls -d *x* 2>/dev/null)
do
if [[ $i =~ [0-9]+x[0-9]+ ]]
then
echo $i
ls *.jpg *.JPG 2>/dev/null | while read f
do
if ! [ -f $i/$f ]
then
echo $f
convert $f -resize "$i^" -gravity center -crop $i+0+0 +repage -quality 80 $i/$f
cwebp $i/$f -q 80 -o $i/$(basename $f .jpg).webp 2>/dev/null
fi
done
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment