Phone Photos No Longer Upload Sideways
prep-images-for-embed now turns phone photos upright before it strips their metadata, and lets genuine portrait shots through.
Why Care?
A booth photo from a conference floor, shot portrait on a phone, went up to the CDN lying on its side. Nothing errored. It just looked wrong on the page, and the only fix was to delete it and upload it again by hand.
Any portrait phone photo would have done the same, and conference write-ups are full of them.
What's New?
Photos come out upright. The script reads each image's EXIF Orientation and rotates or flips the pixels to match before anything else happens. All eight orientation values are handled.
Portrait is allowed, landscape preferred.
--widthnow caps the long side: landscape lands at 1600 wide, a genuine portrait photo at 1600 tall (1200×1600). The script flags portrait output so the embed can use a narrower figure.Tall images get resized too. The old check compared only width, so a tall, narrow image could skip resizing entirely.
Under the Hood
A phone camera saves pixels in the sensor's orientation and adds a flag telling
viewers how to turn them. sips ignores that flag, and the script's next step,
exiftool -all=, deletes it. The result was sideways pixels with no instruction
left to fix them.
The fix reads the flag with exiftool (falling back to ImageMagick's magick,
and warning if neither is installed), then applies sips --rotate and
sips --flip steps before resizing and stripping. Tested with red-and-blue test
cards stored at orientations 3, 6 and 8, a real portrait phone photo
(orientation 6) and a landscape photo with no flag: all five came out upright at
the expected size.