Skip to content

Instantly share code, notes, and snippets.

@huzecong
Created August 9, 2024 05:04
Show Gist options
  • Save huzecong/8bbfe7d43058714b42804ac8061ab967 to your computer and use it in GitHub Desktop.
Save huzecong/8bbfe7d43058714b42804ac8061ab967 to your computer and use it in GitHub Desktop.
Repair HEIF files produced by Sony cameras to show up with the correct orientation in iOS Photos.
#!/usr/bin/env bash
# Usage: ./fix-sony-heif /path/to/directory/with/photos
# Works by fixing EXIF rotation info and renaming .HIF to .HEIC.
# Based on discussion here: https://www.reddit.com/r/SonyAlpha/comments/173qnzg/comment/kr4dcoc/
if [ $# == 1 ]; then
cd $1
fi
exiftool '-Orientation<CameraOrientation' -ext hif * -r
rm *.HIF_original
for x in $(ls *.HIF); do
mv -- "$x" "${x%.HIF}.HEIC"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment