forgot password?
need an account?

Notifications close x

Web Intersect 2 Add On _ Auto Rotate Mobile Images

loading social widgets...
LewisAndersonWritten By: LewisAnderson   flag
Publish Date: February 13, 2015
This add on will detect if an image needs rotated and rotate as needed. This helps when people upload a pic from a mobile device and they have their device rotated. Most mobile devices set an extra bit of meta data instead of actually rotating the image. Code we added to photo_system.php
function change_orientation($path){ $exif = exif_read_data($path); if(isset($exif['Orientation']) && $exif['Orientation'] != "1"){ $position = $exif['Orientation']; $degrees = ""; if($position == "8"){ $degrees = "90"; } else if($position == "3"){ $degrees = "180"; } else if($position == "6"){ $degrees = "-90"; } if($degrees == "90" || $degrees == "180" || $degrees == "-90"){ $source = imagecreatefromjpeg($path); $rotate = imagerotate($source, $degrees, 0); imagejpeg($rotate, realpath($path)); imagedestroy($source); imagedestroy($rotate); } } }
and
$spinPic = change_orientation("../user/$log_username/$db_file_name");
You can read more articles by LewisAnderson by clicking this link:
Articles written by LewisAnderson

User Notes And Comments ↓

Monday October 12, 2015 05:40:59 AM
Argie said:thank you so much appreciate a lot
Tuesday February 02, 2016 02:38:10 AM
Neanrakyr said:Thanks you it's help me a lot :)
Thursday February 04, 2016 01:07:10 PM
bryant said:Does this work with "Non-Mobile" images? Such as one taken with a camera and then stored on the PC, or one scanned in?
Thursday February 04, 2016 01:14:15 PM
LewisAnderson said:I ...think.... this is a mobile only thing, the device sets that orientation exif data. You can always try it out though
Thursday February 04, 2016 01:30:47 PM
bryant said:Will do. I'm trying to work out a system to let the users rotate an uploaded image. Just hoping this would save that step on at least a few of them.
Thursday February 04, 2016 01:44:30 PM
LewisAnderson said:you can rotate with php..google it...just be careful how many times you save the image, jpegs loose quality every time you save them.when dealing with rotations i always let the user goof around to find the rotation then apply that....
Thursday February 04, 2016 01:44:48 PM
LewisAnderson said:....rotation to a master image to be saved
Thursday February 04, 2016 01:45:52 PM
LewisAnderson said:lol...they lose quality, not loose quality...sorry about that
Thursday February 04, 2016 05:57:41 PM
bryant said:Yea. I read that on one of your threads before. I was thinking about making either a javascript function or a canvas element so the user can rotate to the way they want before saving. That way there is only one new save and very little quality drop.
Thursday February 04, 2016 05:58:04 PM
bryant said:Maybe I should start a thread for this? Think this would be an interesting project for readers?
© 2015 webintersect.com
There is a top-shelf free educational course of videos associated with this domain, all about how to build custom communities and social network websites. There are over 45 videos in the course totaling just over 10 hours. We also archived the deprecated course material here for you to reference on the source files page.