On Rails 5.2 I am trying to save an avatar via ActiveStorage but it seems as though not image oriantation data is being saved in the active storage blob.
I am saving the avatar via a file_field on a create action my
#user model
has_one_attached :avatar
private
def avatar_validation
if avatar.attached?
if avatar.blob.byte_size > 1000000
avatar.purge
errors.add(:avatar, 'file is too large')
elsif !avatar.blob.content_type.in?(%w[image/png image/jpg
image/jpeg])
avatar.purge
errors.add(:avatar, 'file type needs to be JPEG, JPG, or PNG')
end
end
end
I have been reading some documentation for minimagick https://github.com/minimagick/minimagick but have not figured out how I can associate
user.avatar.blob
with
image = MiniMagick::Image.open("input.jpg")
I have tried
image = MiniMagick::Image.open("user.avatar.blob")
but have had no luck
I need to try and figure this out because some avatars stored in active storage are being displayed rotated 90 degrees.
https://edgeguides.rubyonrails.org/active_storage_overview.html talks of image processing but I have also had no luck with the gem rails recommends