humanmade / tachyon-plugin

WordPress plugin for Tachyon
https://engineering.hmn.md/projects/tachyon/
83 stars 15 forks source link

Reverse width and height for images rotated 90 degrees #36

Open peterwilsoncc opened 6 years ago

peterwilsoncc commented 6 years ago

WordPress does not modify images containing an EXIF orientation (eg from an iPhone), this causes the width and height to be recorded in the meta data incorrectly for images rotated 90 degrees.

When processing images, the sharp library does rotate images containing an EXIF orientation.

This can lead to an incorrect crop via Tachyon as the Tachyon Plugin sets the arguments to fit={height},{width}.

To crop the image correctly, the meta data's width and height need to be reversed for images rotated 90 degrees.

See peterwilsoncc/doitlive.peterwilson.cc#73 for a sample filter on the hook wp_get_attachment_metadata.