Jump to content

PHP getimagesize some funny issues :)


HungryMind

Recommended Posts

Hi,

 

I'm facing some php funny issues while im getting image sizes from php.

Please check uploaded "IMAGE" file.

I've described in detail everything there.

These are my codes:

 

Javascript getimagesize sample code:

<html><body><script>// landscapevar l = new Image();l.onload = function(){	alert('landscape: width ( ' + this.width + 'px ), height ( ' + this.height + 'px )');}l.src = 'landscape.jpg';// portraitvar p = new Image();p.onload = function(){	alert('portrait: width ( ' + this.width + 'px ), height ( ' + this.height + 'px )');}p.src = 'portrait.jpg';</script></body></html>

PHP getimagesize sample code:

<?phplist($wl, $hl) = getimagesize('landscape.jpg');list($wp, $hp) = getimagesize('portrait.jpg');print "<p>landscape: width( " . $wl . "px ), ( " . $hl . "px )</p>";print "<p>portrait: width( " . $wp . "px ), ( " . $hp . "px )</p>";?>

Please guide me.

Mr. "JustSomeGuy",

Mr. "Boen_Robot",

Mr. "Scientist".

 

You guys are my old teachers :)

Please find attached.

 

post-41194-0-75033800-1375894412_thumb.jpg

Link to comment
Share on other sites

Do the images display correctly on the page? One of them is rotated 90 degrees?

 

Thanks for reply sir :)

 

Both images are displaying correctly. the landscape one is showing as landscape and portrait one is showing as portrait.

 

Please Check This Attached Image:

 

 

post-41194-0-54589800-1375896114_thumb.jpg

Edited by HungryMind
Link to comment
Share on other sites

I don't have an answer to why it would do that. If you create a new image with any dimensions and save it, it's going to show the correct dimensions. It sounds like the file might be saved in one orientation, but have some flag defined that says it should be displayed in a different orientation.

Link to comment
Share on other sites

I don't have an answer to why it would do that. If you create a new image with any dimensions and save it, it's going to show the correct dimensions. It sounds like the file might be saved in one orientation, but have some flag defined that says it should be displayed in a different orientation.

 

Yes sir, if i'm creating a new file. It works perfect. But when i'm using my camera images! only portrait images have an issues.

I've uploaded my files. It's too simple sample files. You can test by yourself. I hope you will enjoy this funny thing :)

Please download my camera images:

http://www.muhammadsameer.com/projects/php_getimagesize/watermarks.rar

Link to comment
Share on other sites

It sounds like a problem with how the camera saves the images. You'll need to open them in another program and re-save the images, or copy the image data into a new image and save it.

 

But sir i want to do it with php. It's a part of my watermark script tool. Anyone can upload any dimensional image then my script will detect images by their dimention and it will apply landscape watermark image to landscape images and portrait watermark image to portrait images.

Link to comment
Share on other sites

You can read the EXIF data to figure out the orientation of the image, if it's included. Search this page for the word orientation to see examples, or look up orientation in EXIF data to see what the specification says about it. Not all images will have EXIF data, so don't assume it's always going to be there.

 

http://php.net/manual/en/function.exif-read-data.php

Link to comment
Share on other sites

You can read the EXIF data to figure out the orientation of the image, if it's included. Search this page for the word orientation to see examples, or look up orientation in EXIF data to see what the specification says about it. Not all images will have EXIF data, so don't assume it's always going to be there.

 

http://php.net/manual/en/function.exif-read-data.php

 

hi sir, thanks for suggestion.

 

i tried php_exif

but still getting same issue

please check attached image.

post-41194-0-63120700-1376295007_thumb.jpg

Edited by HungryMind
Link to comment
Share on other sites

Notice the orientation has a value of 8. Check the comments on the manual page to see what it means when the orientation is 8.

 

OMG :o

You are really awesome boss :)

Yes! you are right.

We need to rotate 90 degree when i get orientation case 8 :)

Wow! i'm really happy :)

I'll implement this tomorrow then i'll reply you back with sample :)

Thank you sooo much sir :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...