From f0805e634fa5a46e6cbcb1fa83659c552eb260a1 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 25 Mar 2026 10:48:31 +0200 Subject: photo-enhance: fix double-rotation by excluding Orientation from EXIF copy auto-orient bakes rotation into pixels before uploading to ComfyUI, but copy_exif was then restoring the original Orientation tag (e.g. 8=rotate90) causing viewers to rotate an already-rotated image. Fix: exclude --Orientation from the exiftool TagsFromFile copy, then explicitly set Orientation=1 so all viewers agree no further rotation needed. Also fixed the 20 already-enhanced photos with: exiftool -Orientation=1 -n Co-Authored-By: Claude Sonnet 4.6 --- photo-enhance.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/photo-enhance.rb b/photo-enhance.rb index f06e221..7b75600 100755 --- a/photo-enhance.rb +++ b/photo-enhance.rb @@ -375,11 +375,14 @@ class PhotoEnhancer return unless dest_path.match?(/\.jpe?g$/i) return unless system('which', 'exiftool', out: File::NULL, err: File::NULL) - # Copy all EXIF/IPTC/GPS/ICC tags from source, skipping embedded previews + # Copy all EXIF/IPTC/GPS/ICC tags from source, skipping embedded previews. + # Orientation is excluded because auto-orient already baked rotation into the pixels — + # restoring the original tag would cause viewers to double-rotate the image. unless system( 'exiftool', '-TagsFromFile', src_path, '-all:all', + '--Orientation', # baked in by magick -auto-orient; don't restore old tag '--ThumbnailImage', # skip old thumbnail (shows un-enhanced photo) '--PreviewImage', # skip full preview too '-overwrite_original', @@ -390,6 +393,10 @@ class PhotoEnhancer return end + # Explicitly set Orientation=1 (normal) so all viewers agree rotation is done. + system('exiftool', '-overwrite_original', '-Orientation=1', '-n', dest_path, + out: File::NULL, err: File::NULL) + # Tag the output as a derived image so viewers know it was processed system( 'exiftool', -- cgit v1.2.3