If you use Active Storage variants to generate thumbs and your thumbnails are sometimes misoriented, you may have EXIF metadata problems For example:
- the original image can have an EXIF metadata specifying a 90° rotation
- when resizing by default
libvips
will apply this rotation to the pixels - HOWEVER it will also preserve the EXIF metadata including this rotation info
- so the thumbnail is doubly rotated
a solution is to remove all EXIF metadata from the generated thumbs by using saver: { strip: true }
in the config:
has_many_attached :photos do |attachable|
attachable.variant :medium, resize_to_limit: [800, 800], saver: { strip: true }
end
this documentation is quite hard to understand