String org.apache.commons.imaging.ImageReadException:4 components are invalid or unsupported

I have an upload feature for users (behind a login) that lets them upload jpg/gif files. After upload the files should be resized in a bunch of formats and saved. That doesn’t always work, for reasons I’m not really sure about but most likely related to threads being blocked by other large uploads. So I have a scheduled task that runs every 15 minutes and checks if there are any outstanding images and then processes those. I’m getting the above error from time to time and it won’t go away unless I download the image, open it in photoshop, then save it for web and re-upload, at which time it processes just fine (same size and all). What could this be?!

This is a feature just for staff in our office to upload images linked to schools they are responsible for, so we’re not talking thousands of images here. 216 have been uploaded so far (in the space of a week) and I’ve had this error occur on about 4 or 5 of the images, but it’s enough that it’s annoying :slight_smile:

Tips/ideas?!

Here is some more error detail.

Error Catch
additional Struct (ordered)
Detail string
ErrorCode string 0
Extended_Info string
ExtendedInfo string
Message string org.apache.commons.imaging.ImageReadException:4 components are
invalid or unsupported
StackTrace string lucee.runtime.exp.NativeException:
org.apache.commons.imaging.ImageReadException:4 components are invalid or
unsupported
	at lucee.runtime.exp.NativeException.newInstance(NativeException.java:73)
	at lucee.runtime.op.Caster.toPageException(Caster.java:3201)
	at lucee.runtime.op.Caster.toPageException(Caster.java:3176)
	at lucee.runtime.img.Image.createImage(Image.java:1521)
	at lucee.runtime.functions.image.ImageRead.call(ImageRead.java:30)
	at components.tasks_cfc$cf.udfCall4(/components/tasks.cfc:673)
	at components.tasks_cfc$cf.udfCall(/components/tasks.cfc)
	at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106)
	at lucee.runtime.type.UDFImpl._call(UDFImpl.java:338)
	at lucee.runtime.type.UDFImpl.call(UDFImpl.java:225)
	at lucee.runtime.type.scope.UndefinedImpl.call(UndefinedImpl.java:772)
	at
lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:758)
	at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1701)
	at components.tasks_cfc$cf.udfCall4(/components/tasks.cfc:655)
	at components.tasks_cfc$cf.udfCall(/components/tasks.cfc)
	at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106)
	at lucee.runtime.type.UDFImpl._call(UDFImpl.java:338)
	at lucee.runtime.type.UDFImpl.call(UDFImpl.java:225)
	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:697)
	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:580)
	at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1918)
	at
lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:758)
	at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1701)
	at
scheduled_tasks.process_school_photos_cfm$cf.call(/scheduled_tasks/process_school_photos.cfm:10)
	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:928)
	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:842)
	at
lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:224)
	at
lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:43)
	at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2408)
	at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2398)
	at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2366)
	at lucee.runtime.engine.Request.run(Request.java:34)
TagContext Array

Does your code check for image size prior to upload? If not, then you may need to look at the actual image sizes, as if there is a commonality such as, file size.

Modify the web.config and add this at the end.

<system.web>
      <httpRuntime maxRequestLength="20480" />
</system.web>

Restart Lucee.

That will allow for 20 meg files to be handled.

Thanks for the input. Size was the first thing that came to mind. The files are actually uploaded, so I have checked those as it happened and there is no common denominator. There were a few under 200kb, and a few around the 1.5-2meg mark. There’s also a bunch uploaded that are smaller, in between and way larger and that processed just fine…

which version of lucee are you using?

Lucee 5.2.1.9 - just set it up totally fresh a few weeks ago. On Ubuntu (digital ocean).

Have you checked to see if the images are CMYK rather than RGB. This causes us problems from time to time …

Hi Martin, the last one was indeed CMYK. I’m going to screenshot the info part of each image that gives trouble over the next few days/weeks and see if I can find a pattern. How do you work around this issue? Is this is a Lucee problem, or something in the java?

Hi Sam,

I think that the Java libraries used within Lucee simply cannot handle the CMYK images.

I have looked at a few workarounds before but never actioned anything. It is infrequent enough for us to re-save the images as RGB. The links below are old, but might help.

https://www.bennadel.com/blog/2458-reading-images-with-fallback-approaches-in-coldfusion.htm

http://digitalrewind.com/cfimage/cfml/coldfusion/imagemagick/2010/08/15/cfimage-cmyk-workaround-to-rgb.html

ah yeah, i remember this problem now.

the commons imaging jar in lucee was last updated in 2014

TwelveMonkeys ImageIO handles CMYK and was last updated in Feb 2017 https://haraldk.github.io/TwelveMonkeys/

It’s definitely worth filing a bug with a sample image https://luceeserver.atlassian.net/

1 Like

Thanks for the replies guys; glad to at least have tracked down the reason. This way I can put some fallback code in place and just email those images to myself for re-uploading or some such. Like Martin, I hope/assume this isn’t going to happen that often. I can also warn staff about this to minimize the problem. As soon as it happens again I’ll also file a bug report with that image.

We generally integrate a SaaS service like:

But seems like TwelveMonkeys would be a great way to improve base functionality overall.


@micstriit would we upgrade the existing CFIMAGE libs or introduce an alternative extension for something like the TwelveMonkeys libs?

The image functiinality already is an extension. The best approach is to use that lib and make a new version in beta state. If the new extension is incompatible. We release as different extension.

Sam, Did you find a work around for this? My image does upload but just displays an error. Is there a way to bypass the error for the client?

There was a bug filed and acknowledged here: https://luceeserver.atlassian.net/browse/LDEV-1388

My workaround has just been to have the wrong ones emailed to me and fixing them manually. They are thankfully few and far between. You could probably do a check of the message string and then replace the error with something a bit more user friendly if this was public facing code?