by Tomas Valent — 23 January 2019

Imagine you are using Rails 5.2 ActiveStorage. Now you upload an image, render it with app.url_for my_model.image.variant(resize: '400x300') and discover that it’s rotated 90 deg to you would normally expect. You copy paste the link to the image to the browser and discover the image is rotated correctly. How is that possible?

This is due to the fact that original image may have had EXIF rotation image metadata (e.g. if photo taken from iPhone, and rotation was done) ActiveStorage does nothing to the original EXIF metadata. Now this is not a bad thing but if you discover this being an issue try app.url_for my_model.image.variant(resize: '400x300, auto_orient: true') ( auto_orient will remove the EXIF while rendering the variant)

If you want to learn more read my ticket on Rails Active Storage related to this https://github.com/rails/rails/issues/35028

hope it will save you few hours of debugging