prawn icon indicating copy to clipboard operation
prawn copied to clipboard

JPEGs rendered with wrong orientation

Open pekeler opened this issue 10 years ago • 2 comments

Prawn seems to ignore the orientation metadata in JPEGs. For example: http://www.coursewalkapp.com/test/Landscape_Orientation_3_Rotated_180.jpg look at this image in a browser or image viewer, and then compare it to the output of

    Prawn::Document.generate("hello.pdf") do |pdf|
      pdf.image open("http://www.coursewalkapp.com/test/Landscape_Orientation_3_Rotated_180.jpg")
    end

pekeler avatar Jun 14 '14 17:06 pekeler

We definitely don't do anything with orientation currently.

You can investigate further and consider preparing a patch if you'd like.

practicingruby avatar Jun 14 '14 23:06 practicingruby

Here is my workaround using MiniMagick:

if content_type == 'image/jpeg'
  image = MiniMagick::Image.read(content_data_io)
  image.auto_orient
  content_data_io = StringIO.new(image.to_blob)
end

donv avatar May 10 '21 20:05 donv