1

I am uploading images to s3 using fog and carrierwave. I am using the below code for profile picture:

version :listpic do
     process :resize_to_fill_modfied => [100, 100] 
   end

    version :usershow do
     process :resize_to_fill_modfied => [225, 225] #user profile pic kullanılıyor
   end

   def resize_to_fill_modfied(width, height, gravity=::Magick::CenterGravity)
      manipulate! do |img|
        img.crop_resized!(width, height, gravity) unless (img.columns <= width && img.rows <= height)
        img = yield(img) if block_given?
        img
      end
    end

The problem is, when I try to upload an image 193x193 it rotates to 90 degrees to left. Why is that?

EDIT

When I try to upload 250x250 it again rotates.

Kirti Thorat
  • 52,578
  • 9
  • 101
  • 108
Shalafister's
  • 761
  • 1
  • 7
  • 34
  • have you trued with the option mentioned here http://stackoverflow.com/questions/18519160/exif-image-rotation-issue-using-carrierwave-and-rmagick-to-upload-to-s3 ? – fanta May 01 '17 at 19:13
  • I very recently had this same issue. I'm assuming these images were taken with a smartphone. I'm not using carrierwave, but I used `auto_orient` from graphicsmagick to rotate the image correctly. There was one caveat, which is that auto_orient doesn't remove the EXIF that is causing the rotation in the first place, so I had to use auto_orient and *then* strip EXIF data. – Brennan May 01 '17 at 19:18
  • You can use the tool at http://metapicz.com/ to see what exif data your image has. You'll see exactly why it's being rotated – Brennan May 01 '17 at 19:20
  • I have tried all the solutions but none working. – Shalafister's May 01 '17 at 19:54

1 Answers1

2

I see from the comments on the question that you've "tried all the solutions," but have you installed MiniMagick?

# Add this in your Gemfile after CarrierWave and Fog:
gem 'mini_magick'
# then run `bundle install` 

Once you've done that, try again with this in the uploader:

def fix_exif_rotation 
  manipulate! do |img|
    img.tap(&:auto_orient)
  end
end
Pardeep Dhingra
  • 3,916
  • 7
  • 30
  • 56
dnicole
  • 21
  • 2
  • But I use RMagick, can I do the same thing with RMagick? – Shalafister's May 03 '17 at 12:41
  • MiniMagick is an alternative for RMagick. It looks like you should be able to do something similar with RMagick, but I can only speak to that what I posted above works for me with MiniMagick. https://rmagick.github.io/image1.html#auto_orient – dnicole May 04 '17 at 04:01