Skip to content

Commit

Permalink
Add script for auto-rotating and resizing images
Browse files Browse the repository at this point in the history
  • Loading branch information
twaugh committed Jan 18, 2017
1 parent b751186 commit 0cd8f59
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rotate-imgs.sh
@@ -0,0 +1,16 @@
#!/bin/bash

for f in "$@"
do
CONV_PARAMS="-interpolative-resize 1024x1024"
mimetype=$(file "$f" | sed -e 's,^[^:]*: \([^ ]*\) .*$,\1,')
if [ "$mimetype" == "JPEG" ]; then
jhead -autorot "$f" && jhead -norot "$f"
elif [ "$mimetype" == "PNG" ]; then
CONV_PARAMS="$CONV_PARAMS -auto-orient"
else
echo "Unhandled: $f ($mimetype)"
break
fi
convert $CONV_PARAMS "$f" "tmp-$f" && mv "tmp-$f" "$f"
done

0 comments on commit 0cd8f59

Please sign in to comment.