prawnpdf / prawn

Fast, Nimble PDF Writer for Ruby
https://prawnpdf.org
Other
4.68k stars 688 forks source link

JPEGs rendered with wrong orientation #733

Open pekeler opened 10 years ago

pekeler commented 10 years ago

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
practicingruby commented 10 years ago

We definitely don't do anything with orientation currently.

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

donv commented 3 years ago

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