Leave That Thing Alone Blog

Viewing By Entry / Main
17 Apr. 2008

Here's a ColdFusion 8 function to rotate digital photographs via Exif 'orientation'. This function will accept a cfimage or a filename and return a rotated/flipped (if needed) image in cfimage format.

With ColdFusion 8's 'ImageGetEXIFMetadata' tag you can get the 'orientation' of a digital photograph. The 'orientation' value indicates if the camera was held/rotated landscape, upside down, portrait with right on the top, etc.

What makes this a bit more difficult is that there are 8 different orientation possibilities and the 'orientation' value can be a number or comma separated text. For example value 1== 'top, left side'. Full exif 'orientation' details here.


Example usages of imageExifOrientationRotate:

<!--- specify image via filename --->
<cfset myImage = imageExifOrientationRotate('IMG_3087.jpg') />
<!--- resize --->
<cfset imageResize(myImage,"200","") />
<!--- display --->
<cfimage action="writeToBrowser" source="#myImage#" />

or

<!--- read image --->
<cfimage action="read" source="IMG_3087.jpg" name="myImage" />
<!--- specify image via cfimage --->
<cfset myImage = imageExifOrientationRotate(myImage) />
<!--- resize --->
<cfset imageResize(myImage,"200","") />
<!--- display --->
<cfimage action="writeToBrowser" source="#myImage#" />

View imageExifOrientationRotate function:

Comments

There are no comments for this entry.