Copy link to clipboard
Copied
We just upgraded to Coldfusion 8 and I am replacing our java JAI thumbnail creation code with ImageScaleToFit and cfimage to write the new thumbnail image. It is working and the properties of the image show that I am scaling correctly and the new thumbnails are the same height and width as ones created using the java code. BUT... the actual filesize of the some of the coldfusion created images is much larger. For example for a thumbnail that is 100x66, the coldfusion file size is 10.5KB while the java created file is 3KB. I think that this happens for images that used to fail before we applied the 8.0.1 hotfix. Images that worked with the plain 8.0.1 seem to be the same size as the java created ones. Anybody seen this?
Copy link to clipboard
Copied
Some more info...When you run your cursor over the java create thumbnail it displays data for Dimensions, Type, and Size. The coldfusion created file shows Dimensions, Date Picture Taken, Camera Model, Type and Size. So, it would seem like the coldfusion created thumbnail contains more information than the one we created with JAI. If this is indeed the reason that the image is so much larger, anybody have any idea of how to get rid of that info?
Copy link to clipboard
Copied
Figured it out. The extra bytes come from the EXIF data. I googled and found a solution to remove it.
Copy link to clipboard
Copied
Glad you solved it. Can you post the solution (for anyone else looking)?
Copy link to clipboard
Copied
Here is how i did it.
<!--- arguments.imageFileName is the full file path/name for the image file --->
<!--- arguments.netImageFileName is the full file path/name for the new thumbnail image file--->
<!--- Application.ThumbnailSize is the max height or width (pixels) for a thumbnail --->
<cfscript>
// Read the image that we are thumbnailing
myImage = ImageRead("#arguments.imageFileName#");
// Resize the image
if (myImage.height > myImage.width) {
ImageScaleToFit(myImage,"",#Application.ThumbnailSize#,"highestPerformance");
}
else {
ImageScaleToFit(myImage,#Application.ThumbnailSize#,"","highestPerformance");
}
// The next code will remove any EXIF headers from JPG files
newImage = ImageNew("",myImage.width, myImage.height,"rgb");
clipboard = ImageCopy(myImage,0,0,myImage.width,myImage.height);
ImagePaste(newImage,clipboard,0,0);
// Write the new thumbnail image
ImageWrite(newImage,"#arguments.newImageFileName#");
</cfscript>