Skip to content

Instantly share code, notes, and snippets.

@ryanburnette
Last active June 4, 2023 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanburnette/9890ab91cf1e32ceab52031cdf4df35c to your computer and use it in GitHub Desktop.
Save ryanburnette/9890ab91cf1e32ceab52031cdf4df35c to your computer and use it in GitHub Desktop.
Remove rotation jpeg exif/meta and resave the file without it. Requires imagemagick and exiftool. https://ryanburnette.com/blog/imageoptim-rotation-information-loss/
#!/bin/sh
if [ -z "$1" ]; then
echo "Usage: $0 <directory>"
exit 1
fi
dir="$1"
if [ ! -d "$dir" ]; then
echo "Error: '$dir' is not a directory"
exit 2
fi
for file in "$dir"/*.jpg; do
if [ -f "$file" ]; then
echo "Processing: $file"
mogrify -auto-orient "$file"
exiftool -Orientation= -n -overwrite_original "$file"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment