- August 17, 2017
- Posted by: user
- Category: Uncategorized
Initially, there was an issue with some photos that are uploaded on website and uploaded photos rotated (left, right or vertically) automatically.
|Before Upload||After Upload|
Later we found the actual issue and there is an issue with photos capture on iPhone by rotating phone and that are rotated after uploads.
Here photos taken on apple device and it adds the orientation rules to EXIF metadata of image. So based on that info you can correct the rotated photo. Here we correct photo orientation using below lucee code.
Error when loading gists from https://gist.github.com/.
<cfset var oImage1 = ImageNew(imgFilePath)>
<cfset var oImage2 = imageNew(ImageGetBufferedImage(oImage1))>
<cfset var imgEXIFinfo = ImageGetEXIFMetadata(oImage2)>
<cfif isStruct(imgEXIFinfo) AND structKeyExists(imgEXIFinfo,"Orientation")>
<cfset var angleValue = "">
<cfset var angleRegEx = "\(Rotate ([\d]+)">
<cfset var arrMatched = REmatchNoCase(angleRegEx,imgEXIFinfo.Orientation)>
<cfif arrayLen(arrMatched) eq 1>
<cfset angleValue = reReplaceNoCase(arrMatched,angleRegEx,"\1")>
<cfset imageRotate(name = oImage2, x = 0, y = 0, angle = angleValue, interpolation = "bicubic")>
So using the orientation angel value we can rotate the image and we get image in correct orientation.
Hope this my experience help you.