HungryMind Posted August 7, 2013 Share Posted August 7, 2013 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. Link to comment Share on other sites More sharing options...
justsomeguy Posted August 7, 2013 Share Posted August 7, 2013 Do the images display correctly on the page? One of them is rotated 90 degrees? Link to comment Share on other sites More sharing options...
HungryMind Posted August 7, 2013 Author Share Posted August 7, 2013 (edited) 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: Edited August 7, 2013 by HungryMind Link to comment Share on other sites More sharing options...
justsomeguy Posted August 7, 2013 Share Posted August 7, 2013 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 More sharing options...
HungryMind Posted August 7, 2013 Author Share Posted August 7, 2013 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 More sharing options...
justsomeguy Posted August 7, 2013 Share Posted August 7, 2013 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. Link to comment Share on other sites More sharing options...
HungryMind Posted August 7, 2013 Author Share Posted August 7, 2013 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 More sharing options...
justsomeguy Posted August 7, 2013 Share Posted August 7, 2013 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 More sharing options...
HungryMind Posted August 12, 2013 Author Share Posted August 12, 2013 (edited) 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. Edited August 12, 2013 by HungryMind Link to comment Share on other sites More sharing options...
justsomeguy Posted August 12, 2013 Share Posted August 12, 2013 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. Link to comment Share on other sites More sharing options...
HungryMind Posted August 12, 2013 Author Share Posted August 12, 2013 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 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now