Portrait getting wrong orientation

See all posts Reply

Portrait getting wrong orientation new!
by Rick, 15 years, 9 months ago
When I upload a portrait image, the image does resize correctly but only the orientation get changed. The resized image rotates 90 degrees CC.

My upload.php:
include('class.upload.php');

$foo  =  new  Upload($_FILES['afb1']);  
if  ($foo->uploaded)  {
   //  save  uploaded  image  with  a  new  name,
   //  resized  to  100px  wide
   $foo->file_new_name_body  =  'image_resized';
   $foo->image_resize  =  true;
   $foo->image_x  =  450;
   $foo->image_y  =  600;
   $foo->image_ratio  =  true;
   $foo->Process('/var/www/nl/domain/www/images/');
   if  ($foo->processed)  {
     echo  'image  resized';
     $foo->Clean();
   }  else  {
     echo  'error  :  '  .  $foo->error;
   }
}

The script works perfectly with landscape images. I really hope you can help me with this. I really like this script!Reply
Re: Portrait getting wrong orientation new!
by Rick, 15 years, 9 months ago
I've discovered something strange. I really don't understand it. Apparently portrait images sometimes do get resized correctly.

When I upload an image with a resolution of 1944 x 2592 (width x height), the image gets resized correctly. (it fits into the container of 450 x 600 pixels)

When I upload an image (a photo) with a resolution of 1200 x 1600 (width x height), the image gets resized correctly.(it also fits into the container of 450 x 600 pixels)

The strange thing is: when I upload an image I made using photoshop (saved as .jpg) with a resolution of 1200 x 1600 (width x height), the image does fit into the container of 450 x 600 pixels, but only the image is rotated 90 degrees CC within te container.Reply
Re: Portrait getting wrong orientation new!
by colin, 15 years, 9 months ago
It is because the image orientation is embedded into the JPEG meta-data. Your image is rotated in reality, but Photoshop reads the meta-data, and un-rotates it to display it as it was taken.

The class doesn't support yet reading these meta-data.Reply
Re: Portrait getting wrong orientation new!
by colin, 7 years, 9 months ago
This is now implemented in the class, you can grab the latest version of the code on GithubReply