ImageInfo() on certain files causes exceptions in the log, but not on the page

We’re getting a number of apache imaging exceptions written to our application.log files. This happens when user(s) upload a less-than-valid image file which ends up getting run through imageInfo().

<cfset foo = imageInfo(imageRead("./badImage.jpg"))/>

I tried attaching one of the bad images to this post, but it gets resized so I don’t know if it will still be bad. I have uploaded the raw image file here: 43459A.jpg - Google Drive

The page does not throw any exceptions; the user is not affected. But this exception does clutter up the log. Can something be done to silence this exception? I think the problem is happening in the Apache imaging library, from the Lucee image extension.

Might be line 60 of this file? I see in the catch it only does Debug.debug(e);, which might be what is causing these log entries, but not causing a Lucee exception.

FYI the result from ImageInfo() appears correct, even with the bad image.

Window: Windows
Java Version: 11.0.21
Tomcat Version: 9.0.83
Lucee Version: I’ve tried and

I forgot to include the stack trace, here it is.

"ERROR","ajp-nio-","12/21/2023","15:49:29","imaging","Could not read block (block start: 984, block length: -62, data length: 922).; Could not read block (block start: 984, block length: -62, data length: 922).
        at org.apache.commons.imaging.common.bytesource.ByteSourceArray.getBlock(
        at org.apache.commons.imaging.formats.tiff.TiffReader.getJpegRawImageData(
        at org.apache.commons.imaging.formats.tiff.TiffReader.readDirectory(
        at org.apache.commons.imaging.formats.tiff.TiffReader.readDirectory(
        at org.apache.commons.imaging.formats.tiff.TiffReader.readDirectories(
        at org.apache.commons.imaging.formats.tiff.TiffReader.readContents(
        at org.apache.commons.imaging.formats.tiff.TiffImageParser.getMetadata(
        at org.apache.commons.imaging.formats.tiff.TiffImageParser.getMetadata(
        at org.apache.commons.imaging.ImageParser.getMetadata(
        at org.apache.commons.imaging.formats.jpeg.JpegImageParser.getExifMetadata(
        at org.apache.commons.imaging.formats.jpeg.JpegImageParser.getMetadata(
        at org.apache.commons.imaging.formats.jpeg.JpegImageParser.getMetadata(
        at org.apache.commons.imaging.Imaging.getMetadata(
        at org.apache.commons.imaging.Imaging.getMetadata(
        at org.lucee.extension.image.Metadata.addExifInfoToStruct(
        at org.lucee.extension.image.functions.ImageInfo.invoke(
        at lucee.runtime.functions.FunctionHandlerPool.invoke(
        at schedules.test_cfm$cf$
        at lucee.runtime.PageContextImpl._doInclude(
        at lucee.runtime.PageContextImpl._doInclude(
        at lucee.runtime.listener.ModernAppListener._onRequest(
        at lucee.runtime.listener.MixedAppListener.onRequest(
        at lucee.runtime.PageContextImpl.execute(
        at lucee.runtime.PageContextImpl._execute(
        at lucee.runtime.PageContextImpl.executeCFML(
        at lucee.runtime.engine.Request.exe(
        at lucee.runtime.engine.CFMLEngineImpl._service(
        at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(
        at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(
        at lucee.loader.servlet.CFMLServlet.service(

Also some more details here: [IMAGING-177] Could not read block - ASF JIRA

I had similar issues once with errors, but the logs didn’t matter. An alternative to cfimage has always been imagemagick, a commandlne tool that had lot of powerful commands about image manipulation even before cfimage existed.

1 Like