summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-25 10:48:31 +0200
committerPaul Buetow <paul@buetow.org>2026-03-25 10:48:31 +0200
commitf0805e634fa5a46e6cbcb1fa83659c552eb260a1 (patch)
tree92b5389a6031107dd58279ef0d9cfb9e13648309
parentb18dfa9f3988c3ca16c1bd7bd84526b3f6e0fc33 (diff)
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 <noreply@anthropic.com>
-rwxr-xr-xphoto-enhance.rb9
1 files changed, 8 insertions, 1 deletions
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',