//create image var exifRotateImage = imageNew(arguments.image); //get all EXIF tags var exif = ImageGetEXIFMetadata(exifRotateImage); var orientation = ""; var flip = false; var rotateDegrees = 0; //see if 'orientation' exists in the exif if (not structKeyExists(exif,"orientation")) { //NO exif so just return input image return exifRotateImage; } else { //OK we've got a orientation value, onward //set orientation orientation = exif.orientation; //is orientationText text based? if so we need to change them to number based if (ListLen(orientation) >= 2) { if ((listGetAt(orientation,1) contains "top") && (listGetAt(orientation,2) contains "left side")) { orientation = 1; } else if ((listGetAt(orientation,1) contains "top") && (listGetAt(orientation,2) contains "right side")) { orientation = 2; } else if ((listGetAt(orientation,1) contains "bottom") && (listGetAt(orientation,2) contains "right side")) { orientation = 3; } else if ((listGetAt(orientation,1) contains "bottom") && (listGetAt(orientation,2) contains "left side")) { orientation = 4; } else if ((listGetAt(orientation,1) contains "left side") && (listGetAt(orientation,2) contains "top")) { orientation = 5; } else if ((listGetAt(orientation,1) contains "right side") && (listGetAt(orientation,2) contains "top")) { orientation = 6; } else if ((listGetAt(orientation,1) contains "right side") && (listGetAt(orientation,2) contains "bottom")) { orientation = 7; } else if ((listGetAt(orientation,1) contains "left side") && (listGetAt(orientation,2) contains "bottom")) { orientation = 8; } else { orientation = 1; } } //if we've got a number from 1-8 and we may need to rotate and/or flip if (len(orientation) == 1 && isnumeric(orientation)) { //based on orienttation number figure out what image rotation and/or flips need to be done switch(orientation) { case 1:rotateDegrees = 0; flip = false; break; case 2:rotateDegrees = 0; flip = "horizontal"; break; case 3:rotateDegrees = 180; flip = false; break; case 4:rotateDegrees = 0; flip = "vertical"; break; case 5:rotateDegrees = 90; flip = "vertical"; break; case 6:rotateDegrees = 90; flip = false; break; case 7:rotateDegrees = 270; flip = "horizontal"; break; case 8:rotateDegrees = 270; flip = false; break; } //rotate if needed if (rotateDegrees != 0) { //imageRotate(exifRotateImage,rotateDegrees,0,0,arguments.interpolation); //broken(bug filed) function if x&y are specified (in CF8.0.1) imageRotate(exifRotateImage,rotateDegrees); } //flip if needed if (flip != false) { ImageFlip(exifRotateImage,flip); } } //return image return exifRotateImage; }