Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to stop PHP from rotating my images when resizing?

Status
Not open for further replies.

thewhistler1

Technical User
Jan 20, 2008
35
US
I am creating a website that allows uploading of images. The images are resized to certain specs, then placed into a folder. One problem I have is when I upload and resize a photo that is taller than it is wide the photo actually rotates 90 degrees. I am using imagecopyresampled to resize the image. Like this:
Code:
$uploadedfile = $_FILES['uploadfile']['tmp_name'];
$src = imagecreatefromjpeg($uploadedfile);
list($width,$height)=getimagesize($uploadedfile);
$newheight=350;
$newwidth=($width/$height)*350;
$tmp=imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
$filename = $target;
imagejpeg($tmp,$filename,100);
imagedestroy($src);
imagedestroy($tmp)

My question is how to make that function stop rotating my images.

Thanks

 
your code does not rotate the images. it is probable that the images appear properly oriented in your OS but in fact are not
 
When I pull up the dimensions of the picture it says 1000 x 1504 , where the pictures that are wider then they are tall all show 1504 X 1000 so I really don't think that my OS is auto rotating the pictures when displaying them. My Camera does that automatically so that when you import the photos it comes through in a portrait format rather than landscape. So I think the issue has to be something with the code.
Any ideas on how to fix this would be greatly appreciated.
 
are you saying that the code actually rotates the picture? or simply that after the code has run its course the picture is taller than it is wide rather than vice versa.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top