• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Resizing image with maintain_ratio causes unwanted rotation

I'm using the image library to resize images, with maintain_ratio set to true. My problem is that, while this works with landscape images, portrait images are rotated 90 degrees. Here is the body of my resize function:

PHP Code:
$config = array(
'source_image'   => $path.$file_name,
'width'          => 300,
'height'         => 200,
'maintain_ratio' => TRUE
 if (!
$this->image_lib->resize()) return $this->image_lib->display_errors(); 

So this scenario works fine: input is a landscape image, 1920 x 1200, and it gets resized to 300 x 188.

This is the problem scenario: input is a portrait image, 2700 x 3700, which gets resized to 267 x 200 (fine), but rotated left 90 degrees.

I've seen this Stackoverflow question, but none of its attempts to fix were relevant to my situation.

Has anyone else experienced this bug? Any thoughts welcome!

More than likely, the rotation of the image is being set by the EXIF data. There are a few Stackoverflow questions related to correcting the orientation in PHP, but this one looked the most helpful in my quick look at a handful of them: http://stackoverflow.com/questions/36570...-like-desk

I had the same problem and I've lost a lot of time trying to understand it, in the end the only solution I found is to use EXIF data...

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.