From 5a18b172cc7695bf7d907c511236018fb5e156cb Mon Sep 17 00:00:00 2001 From: dece Date: Sun, 17 Sep 2023 16:11:15 +0200 Subject: [PATCH] remove-orientation.sh --- remove-orientation.sh | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 remove-orientation.sh diff --git a/remove-orientation.sh b/remove-orientation.sh new file mode 100755 index 0000000..0e1cc52 --- /dev/null +++ b/remove-orientation.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Remove orientation information from the EXIF metadata WITHOUT touching pixels. +# Can also remove thumbnail because some programs like Ristretto are bugged by +# the remaining thumbnail orientation metadata. Useful when a photo has wrong +# orientation metadata (e.g. buggy LineageOS app). + +usage() { + echo "Usage: $0 [-t] [FILE]" + echo " -t remove thumbnail" +} + +OPT_FLAG_T= +while getopts "ht" OPTION; do + case $OPTION in + h) usage; exit 0 ;; + t) OPT_FLAG_T=true ;; + *) usage; exit 1 ;; + esac +done +shift $(( OPTIND - 1 )) + +for jpg in "$@"; do + echo "Fixing \"$jpg\"…" + exiftool -Orientation= -overwrite_original "$jpg" + if [[ "$OPT_FLAG_T" = true ]]; then + exiftool -IFD1:all= -overwrite_original "$jpg" + fi +done