"java.awt.color.CMMException: Invalid image format" and tried
the solutions posted here with no avail.
We are going to use the power of Java's JAI (Java Advanced Imaging) library to tackle this one.
<cfscript> //path to image imagePath = "pathToImage"; //create java file object, passing in path to image imageFile = createObject("java","java.io.File").init(imagePath); //create a FileSeekableStream, passing in the image file we created fss = createObject("java","com.sun.media.jai.codec.FileSeekableStream").init(imageFile); //create ParameterBlock object and initialize it (call constructor) pb = createObject("java","java.awt.image.renderable.ParameterBlock").init(); //pass in FileSeekableStream pb.add(fss); //create JAI object that will ultimately do the magic we need JAI = createObject("java","javax.media.jai.JAI"); //use the JAI object to create a buffered jpeg image using the parameter block we just created buffImage = JAI.create("jpeg", pb).getAsBufferedImage(); //pass the buffered image to the ColdFusion imagenew() method. New_Image = imagenew(buffImage); //make sure we close the stream, or you'll pay for it later fss.close(); </cfscript>From what I could find CF/Java chokes on some jpeg's due to their format.
Specifically speaking, the EXIF format vs. the JFIF format.
Read this for more information on these two standards.
Some cameras only add the EXIF segment to the file header of the jpeg and images from those cameras are the ones I see issues with.
To see some samples of this, check out the images on this website.
Download some of those images and see if your image processing code can handle them!
To get more information on your images check out this page and it will tell you all about it, including if the image has JFIF or EXIF segments added.
If anyone has questions about the above code, please don't hesitate to ask.
Hope this helps some of you, since I could not find any solution out there.