Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Another CFImage bug

New Here ,
Apr 17, 2008 Apr 17, 2008

Copy link to clipboard

Copied

Second cfImage bug I've found in a week. Tried reporting it to Adobe, but their bug report form throws a 404 (nice).

Basically, certain JPGs will cause CF (or more specifically, Java) to throw this error after reading them to memory, then writing it to disk:
Missing Huffman code table entry
javax.imageio.IIOException: Missing Huffman code table entry at com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeImage(Native Method) at com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:996) at coldfusion.image.ImageWriter.writeJPeg(ImageWriter.java:60) at coldfusion.image.ImageWriter.writeImage(ImageWriter.java:119) at coldfusion.image.Image.write(Image.java:578) at coldfusion.tagext.io.ImageTag.performWrite(ImageTag.java:593) at coldfusion.tagext.io.ImageTag.doStartTag(ImageTag.java:500)

Run the attached code with the image found here:
http://img141.imageshack.us/img141/9549/testimagefk9.jpg

If you put the URL into the cfimage source (instead of downloading the image and reading it locally) you get a different error:
coldfusion.image.Image$ReadImageMetadataException: Exception occured in JPG processing.
segment size would extend beyond file stream length
at coldfusion.image.Image.initializeMetadata(Image.java:2403)
at coldfusion.image.Image.getExifMetadata(Image.java:2415)
at coldfusion.image.Image.write(Image.java:577)
at coldfusion.tagext.io.ImageTag.performWrite(ImageTag.java:593)
at coldfusion.tagext.io.ImageTag.doStartTag(ImageTag.java:500)

Verified on Win2K, Win2K3, and WinXP. CF version 8.0.1.
TOPICS
Advanced techniques

Views

5.1K

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 19, 2008 Apr 19, 2008

Copy link to clipboard

Copied

Did you encounter this problem with 8.0.0? What JVM version are you using? I tested the code using both the url and a local file and both work without error under:

O/S: XP SP2
CF: 8,0,0,176276
JVM: 1.6.0_01

Tried reporting it to Adobe, but their bug report form throws a 404 (nice).
On submit? The form displays correctly for me.
http://www.adobe.com/cfusion/mmform/index.cfm?name=wishform

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 20, 2008 Apr 20, 2008

Copy link to clipboard

Copied

After applying updater 1, I received the two errors you posted above.

O/S: XP SP2
CF: 8,0,1,195765
JVM: 1.6.0_04

Reverting to JVM 1.6.0_01-b06 had no effect on the error. I rolled back to CF 8.0.0 and the errors went away. That does seem to support the theory it is not or not solely a jvm problem. Out of curiosity, is there anything special about these images or do they all have something in common?

Using ImageIO to write the images, instead of cfimage, seems to work with 8.0.1.

<cfscript>
newImageName = createUUID() & ".jpg";
outFile = createObject("java", "java.io.File").init( ExpandPath(newImageName) );
bi = ImageGetBufferedImage(myImage);
ImageIO = createObject("java", "javax.imageio.ImageIO");
ImageIO.write( bi, "jpeg", outFile );
</cfscript>

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 22, 2008 Apr 22, 2008

Copy link to clipboard

Copied

Nothing special about the image that I know of. It was uploaded by one of our users. We get about one image a day that causes this error.

I tried upgrading to JVM 1.6.0_06 but still have the problem.

Interesting that imageIO works when you invoke it directly. The error being generated comes from that class when using the cfimage tag:
javax.imageio.IIOException: Missing Huffman code table entry at com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeImage(Native Method) at com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:996) at coldfusion.image.ImageWriter.writeJPeg(ImageWriter.java:60) at coldfusion.image.ImageWriter.writeImage(ImageWriter.java:119) at coldfusion.image.Image.write(Image.java:578) at coldfusion.tagext.io.ImageTag.performWrite(ImageTag.java:593)

It seems to point to a bug in the implementation of CFImage.


Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 23, 2008 Apr 23, 2008

Copy link to clipboard

Copied

Now that I have worked around the image lock issue I am running into this issue now as well.

Is there anyway to fix it and perform a resize.

Our customer is in a shared hosted environment and as a result we cannot change any CF settings to override how CFImage works.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 23, 2008 Apr 23, 2008

Copy link to clipboard

Copied

Try the method that cfSearching proposed above. Let us know if it fixes the problem for you.

Also, report the bug to Adobe. The more reports the better.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 23, 2008 Apr 23, 2008

Copy link to clipboard

Copied

@hans blix,

Yes I did notice the error is from the same package. However, the calling method is from com.sun.imageio.plugins. While I do not know about the internals of either class, since one works for me and the other does not I can only assume cfimage's method of writing out images is different than ImageIO.write.

My guess is the resize/write problem mentioned your other thread is a bug. This exception may be a bug as well. However, I am not familiar with image compression and decoding. So it may still be a problem with the image files themselves. Though I suspect not.

@DefconRhall,

Try the code snippet above. It should work with 8.0.1. You could use it to replace the cfimage call, or call it if a: "javax.imageio.IIOException: Missing Huffman code table entry" exception is thrown.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 23, 2008 Apr 23, 2008

Copy link to clipboard

Copied

I always like to try and understand code a bit before I implement it..

If I understand that snipet of code I basically want to use it to load up the file I just uploaded, have it save the image on top of itself, and then run the cfimage to do the resize?

Thanks,

PS: Looks like the locking bug with CFImage has been addressed by Adobe

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 24, 2008 Apr 24, 2008

Copy link to clipboard

Copied

@DefconRhall,

Thanks for mentioning the patch for the CF8 image resizing issue.

This error seems to be caused by <cfimage action="write" ..>. [ Update: More accurately the error occurs when you try and write the image to disk ]. So the code snippet above would only replace the write action. You would first resize your image as usual, then use the snippet above to save the resized image to disk.

<cfscript>
newImageName = createUUID() & ".jpg";
// create a file object representing the path to the saved image
outFile = createObject("java", "java.io.File").init( ExpandPath(newImageName) );

// extract the underlying BufferedImage from your CF image object
bi = ImageGetBufferedImage(myImage);

ImageIO = createObject("java", "javax.imageio.ImageIO");
// use ImageIO (instead of cfimage) to physically save the image to disk
ImageIO.write( bi, "jpeg", outFile );
</cfscript>

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 19, 2008 Apr 19, 2008

Copy link to clipboard

Copied

> Did you encounter this problem with 8.0.0? What JVM version are you using? I
> tested the code using both the url and a local file and both work without error
> under:
>
> O/S: XP SP2
> CF: 8,0,0,176276
> JVM: 1.6.0_01

Works fine for me too (same config as per yours above).

--
Adam

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2008 Apr 27, 2008

Copy link to clipboard

Copied

What is odd is it seems to work perfectly fine when I resize the image to like 100x100, however the next line afterwards I resize to like 640x480 and it bombs...

I'll try re-reading the image file before doing the second resize and post the result.

Also by image object I take it you mean the return variable from the cfimage tag.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2008 Apr 27, 2008

Copy link to clipboard

Copied

Well... that just made me look like an idiot, it failed this time on the first try...

I'll try the image object thing it seems I don't have a choice.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 27, 2008 Apr 27, 2008

Copy link to clipboard

Copied

DefconRhall wrote:
Also by image object I take it you mean the return variable from the cfimage tag.

Yes.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2008 Apr 27, 2008

Copy link to clipboard

Copied

Not sure why this doesn't work, so I'll post it here.

It gives me " The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code."

In reference to the line: "ImageIO.write( bi, "jpeg", outFile );"

The bi is defined and so is outfile so what the heck doesn't it like?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 27, 2008 Apr 27, 2008

Copy link to clipboard

Copied

It works perfectly for me.

<cfscript>
// sample values for test script
ThumbWidth = 50;
ThumbHeight = 50;
GetProduct.ThumbNailPhysPath = "SavedFile.jpg";
TestImg=ImageNew(ExpandPath("MyTestImage.jpg"));

ImageResize(TestImg,ThumbWidth,ThumbHeight);
outFile = createObject("java", "java.io.File").init( ExpandPath(GetProduct.ThumbNailPhysPath) );

// extract the underlying BufferedImage from your CF image object
bi = ImageGetBufferedImage(TestImg);

ImageIO = createObject("java", "javax.imageio.ImageIO");
// use ImageIO (instead of cfimage) to physically save the image to disk
ImageIO.write( bi, "jpeg", outFile );
</cfscript>

Dumb question, but are you sure the error is really on that line? If you comment it out does the code work? Also I assume you did an IsDefined on both variables: "bi" and "outFile"?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2008 Apr 27, 2008

Copy link to clipboard

Copied

Yep, if I drop that line it works fine.

Both ImageIO and bi are defined

Maybe the host's servers are messed up and need a reboot?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 27, 2008 Apr 27, 2008

Copy link to clipboard

Copied

Both ImageIO and bi are defined
What about "outFile"? Also what results do you get if you run this code before the ImageIO.write?

<cfdump var="#bi.getClass().getName()#" label="Variable bi class name"><br>
<cfdump var="#outFile.getClass().getName()#" label="Variable outFile class name"><br>
<cfdump var="#bi.getWidth()#x#bi.getHeight()#" label="BufferedImage width x height"><br>
<cfdump var="#outFile.getAbsolutePath()#" label="OutFile Path">

Without seeing the full error, my guess would be the same as yours: one of the two variables is not defined for some reason. Can you post the full error message and stack trace?

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2008 Apr 27, 2008

Copy link to clipboard

Copied

AH HA!

It caught me! With crazy file pathing...

The expandpath was adding the current directory to my full qualified path, thus resulting in "bad mojo".

Chalk this up to me forgetting about the ExpandPath in your example.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Apr 27, 2008 Apr 27, 2008

Copy link to clipboard

Copied

DefconRhall wrote:
The expandpath was adding the current directory to my full qualified path, thus resulting in "bad mojo".

Yes, that would do it 😉 Glad it is working now.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2008 May 05, 2008

Copy link to clipboard

Copied

We upgraded to 8.01 today (Windows 2003 server) and immediately started seeing problems with the CFIMAGE routines. The hotfix hasn't worked for us, though it seems to have made the frequency slightly less.

Our application log shows a few of these every few minutes:

An exception occured while trying to write the image. Ensure that the destination directory exists and that Coldfusion has permission to write to the given path or file. cause : coldfusion.image.ImageWriter$ImageWritingException: An exception occured while trying to write the image.

Is work on this hotfix ongoing? Can we expect to see an update sometime soon?

Or.... my favorite and more typical situation, am I the only one still having this issue? :-)

Many thanks,
- Piper

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 05, 2008 May 05, 2008

Copy link to clipboard

Copied

Piper,

The info in the logs isn't enough to determine which CFImage bug you are experiencing. Your best bet would be to wrap your CFImage logic in cftry/cfcatch and email yourself a dump of the cfcatch structure. Quick and dirty example below.

So far, the workaround is to call the underlying Java methods to manipulate and write images. See above for cfSearching's example.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 06, 2008 May 06, 2008

Copy link to clipboard

Copied

Update: According to Kiran Sakhare a hotfix for the locking and Huffman table issues will be released soon. I do not know if it will also fix the "Quantization table 0x02 was not defined" error.

In the mean time, the full method I am using as a work-around is:
http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=1&catid=7&threadid=1358449

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
May 07, 2008 May 07, 2008

Copy link to clipboard

Copied

Updated hot fix was published today. Visit http://www.adobe.com/go/kb402604 for list of all CF8/8.01 hot fixes. Again, the CFImage hot fix was updated today (5/7/08).

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 07, 2008 May 07, 2008

Copy link to clipboard

Copied

This patch fixed the problem. Thanks for the quick response.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 15, 2008 May 15, 2008

Copy link to clipboard

Copied

Hey Guys,
We tried the latest/greatest CFImage hotfix (updated) yesterday but we started finding the same errors again in the application.log:

An exception occured while trying to write the image. Ensure that the destination directory exists and that Coldfusion has permission to write to the given path or file. cause : coldfusion.image.ImageWriter$ImageWritingException: An exception occured while trying to write the image.

We're still successfully using the java code workaround, but it is noticeably slower than the CFImage writing function, so we had to increase timeouts on the upload pages to deal with that.

Is anyone else still experiencing this issue?

Best,
- Piper

(This is a cross-post from: http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?catid=3&threadid=1356442&STARTPAGE=1&FT...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
    • 1
    • 2