Image Rotate

#1

I’m having an issue with a Lucee function in one of my sites.

The function is ImageRotate(). The issue is that, at some point in the past few months (sorry I don’t think I can narrow it down any more than that) this function stopped working correctly.

It was originally coded it according to the Adobe ColdFusion documentation. https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-functions/functions-h-im/imagerotate.html

The Adobe documentation shows that there are two options and I used the first option.

The Lucee documentation shows only one option which is similar to the second option above. https://docs.lucee.org/reference/functions/imagerotate.html

At the bottom of the Lucee documentation there is a code sample demonstrating how to use the function and it is coded using syntax similar to option 1 in the Adobe documentation:

You can edit the parameter value and run the code, which I did to confirm that the parameter did in fact represent an angle.

In the site, the end user can rotate images using the interface, shown below, by:

  1. Selecting an image and clicking either
  2. The rotate left or
  3. The rotate right buttons

Like I said, this functionality used to work but now we get the following behavior:
· Clicking rotate left rotates the image but corrupts it in doing so (see image below)
o Clicking rotate left again throws an exception with the message, “All factories fail for the operation “bandselect”
· Clicking rotate right immediately throws an exception with the message “1952” or “java.lang.ArrayIndexOutOfBoundsException”

This is what I see in irongate:

And here is the code:

In the site when an image is uploaded we save four different sizes which is why there are four images involved. You can that the code is similar to the sample code in the Lucee documentation.

Any chance someone can shed some light on what is going on here? Is this a bug internal to Lucee?

Any help would be appreciated.

Thank you
Barbara

0 Likes

#2

Can you post

  • the full stacktrace for the exception,
  • which version of Java and Lucee
  • which version of the Image extension are you running? (see under extensions, applications image extension)
0 Likes

#3

Stack trace is below
Lucee Version Lucee 5.2.9.31
Java 1.8.0_191 (Oracle Corporation) 64bit

Thank you

Here you go, I have the stack trace listed for three different exceptions:

All factories fail for the operation "bandselect"The error occurred in E:\Websites\domain\www\cfcs\Image.cfc: Line 365 Called from E:\Websites\domain\www\cfcs\AJAXFunctions.cfc: line 2560
363 :
364 : <cfif ARGUMENTS.Direction EQ “L” >
365 : <cfset ImageRotate(small, “270”) />366 : <cfset ImageRotate(med, “270”) />
367 : <cfset ImageRotate(lrg, “270”) />

domain/Management/ImageLibrary.cfm
Date/Time03-Apr-19 10:10:39 AM
Stack Trace (click to expand)
lucee.runtime.exp.NativeException: All factories fail for the operation “bandselect”
at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1692)
at javax.media.jai.ThreadSafeOperationRegistry.invokeFactory(ThreadSafeOperationRegistry.java:481)at javax.media.jai.registry.RIFRegistry.create(RIFRegistry.java:340)
at javax.media.jai.RenderedOp.createInstance(RenderedOp.java:830)
at javax.media.jai.RenderedOp.createRendering(RenderedOp.java:878)
at javax.media.jai.RenderedOp.getColorModel(RenderedOp.java:2253)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2511)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2559)
at lucee.runtime.img.Image.removeAlpha(Image.java:1368)
at lucee.runtime.img.Image.rotate(Image.java:1314)
at lucee.runtime.functions.image.ImageRotate._call(ImageRotate.java:59)
at lucee.runtime.functions.image.ImageRotate.call(ImageRotate.java:32)
at cfcs.image_cfc$cf.udfCall1(/cfcs/Image.cfc:365)
at cfcs.image_cfc$cf.udfCall(/cfcs/Image.cfc)
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:107)
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:357)
at lucee.runtime.type.UDFImpl.call(UDFImpl.java:226)
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:693)
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:573)
at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1997)
at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:756)
at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1718)
at cfcs.ajaxfunctions_cfc$cf.udfCall4(/cfcs/AJAXFunctions.cfc:2560)
at cfcs.ajaxfunctions_cfc$cf.udfCall(/cfcs/AJAXFunctions.cfc)
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:107)
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:357)
at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:212)
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:695)
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:581)
at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:2022)
at lucee.runtime.ComponentSpecificAccess.callWithNamedValues(ComponentSpecificAccess.java:155)
at lucee.runtime.ComponentPageImpl.callWDDX(ComponentPageImpl.java:664)
at lucee.runtime.ComponentPageImpl.call(ComponentPageImpl.java:210)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:933)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:823)
at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:218)
at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:43)
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2464)
at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2454)
at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2427)
at lucee.runtime.engine.Request.exe(Request.java:44)
at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1090)
at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1038)
at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:102)
at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intergral.fusionreactor.j2ee.filterchain.WrappedFilterChain.doFilter(WrappedFilterChain.java:134)
at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doNext(FusionReactorRequestHandler.java:764)
at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doHttpServletRequest(FusionReactorRequestHandler.java:344)
at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doFusionRequest(FusionReactorRequestHandler.java:207)
at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.handle(FusionReactorRequestHandler.java:801)
at com.intergral.fusionreactor.j2ee.filter.FusionReactorCoreFilter.doFilter(FusionReactorCoreFilter.java:36)
at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intergral.fusionreactor.j2ee.filterchain.WrappedFilterChain.doFilter(WrappedFilterChain.java:71)
at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intergral.fusionreactor.agent.filter.FusionReactorStaticFilter.doFilter(FusionReactorStaticFilter.java:54)
at com.intergral.fusionreactor.agent.pointcuts.NewFilterChainPointCut$1.invoke(NewFilterChainPointCut.java:41)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:486)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: javax.media.jai.util.ImagingException: All factories fail for the operation “bandselect”
… 85 more
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.GeneratedMethodAccessor197.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at javax.media.jai.FactoryCache.invoke(FactoryCache.java:130)
at javax.media.jai.OperationRegistry.invokeFactory(OperationRegistry.java:1679)
… 84 more
Caused by: java.lang.IllegalArgumentException: red mask ff000000 overflows pixel (expecting 24 bits
at java.awt.image.PackedColorModel.DecomposeMask(PackedColorModel.java:280)
at java.awt.image.PackedColorModel.(PackedColorModel.java:209)
at java.awt.image.DirectColorModel.(DirectColorModel.java:182)
at javax.media.jai.PlanarImage.createColorModel(PlanarImage.java:1125)
at com.sun.media.jai.util.ImageUtil.getCompatibleColorModel(ImageUtil.java:1446)
at javax.media.jai.OpImage.layoutHelper(OpImage.java:540)
at javax.media.jai.OpImage.(OpImage.java:839)
at javax.media.jai.PointOpImage.(PointOpImage.java:375)
at com.sun.media.jai.opimage.BandSelectOpImage.(BandSelectOpImage.java:114)
at com.sun.media.jai.opimage.BandSelectCRIF.create(BandSelectCRIF.java:59)
… 89 more

1952

The error occurred in E:\Websites\domain\www\cfcs\Image.cfc: Line 370 Called from E:\Websites\domain\www\cfcs\AJAXFunctions.cfc: line 2560

368 : <cfset ImageRotate(full, 270) />
369 : <!— Rotate Right —>
370 : <cfset ImageRotate(small, 90) />
371 : <cfset ImageRotate(med, 90) />
372 : <cfset ImageRotate(lrg, 90) />

Referrer
domain/Management/ImageLibrary.cfm

Date/Time
03-Apr-19 09:49:33 AM

Stack Trace (click to expand)
lucee.runtime.exp.NativeException: 1952
at com.sun.media.jai.opimage.AffineNearestOpImage.byteLoop_1band(AffineNearestOpImage.java:592)
at com.sun.media.jai.opimage.AffineNearestOpImage.computeRect(AffineNearestOpImage.java:258)
at com.sun.media.jai.opimage.AffineOpImage.computeTile(AffineOpImage.java:626)
at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:912)
at javax.media.jai.OpImage.getTile(OpImage.java:1139)
at javax.media.jai.PlanarImage.copyData(PlanarImage.java:2356)
at javax.media.jai.RenderedOp.copyData(RenderedOp.java:2310)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2538)
at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2559)
at lucee.runtime.img.Image.rotate(Image.java:1332)
at lucee.runtime.functions.image.ImageRotate._call(ImageRotate.java:59)
at lucee.runtime.functions.image.ImageRotate.call(ImageRotate.java:32)
at cfcs.image_cfc$cf.udfCall1(/cfcs/Image.cfc:370)
at cfcs.image_cfc$cf.udfCall(/cfcs/Image.cfc)
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:107)
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:357)
at lucee.runtime.type.UDFImpl.call(UDFImpl.java:226)
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:693)
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:573)
at lucee.runtime.ComponentImpl.call(ComponentImpl.java:1997)
at lucee.runtime.util.VariableUtilImpl.callFunctionWithoutNamedValues(VariableUtilImpl.java:756)
at lucee.runtime.PageContextImpl.getFunction(PageContextImpl.java:1718)
at cfcs.ajaxfunctions_cfc$cf.udfCall4(/cfcs/AJAXFunctions.cfc:2560)
at cfcs.ajaxfunctions_cfc$cf.udfCall(/cfcs/AJAXFunctions.cfc)
at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:107)
at lucee.runtime.type.UDFImpl._call(UDFImpl.java:357)
at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:212)
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:695)
at lucee.runtime.ComponentImpl._call(ComponentImpl.java:581)
at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:2022)
at lucee.runtime.ComponentSpecificAccess.callWithNamedValues(ComponentSpecificAccess.java:155)
at lucee.runtime.ComponentPageImpl.callWDDX(ComponentPageImpl.java:664)
at lucee.runtime.ComponentPageImpl.call(ComponentPageImpl.java:210)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:933)
at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:823)
at lucee.runtime.listener.ModernAppListener._onRequest(ModernAppListener.java:218)
at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:43)
at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2464)
at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2454)
at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2427)
at lucee.runtime.engine.Request.exe(Request.java:44)
at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1090)
at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:1038)
at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:102)
at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at sun.reflect.GeneratedMethodAccessor91.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intergral.fusionreactor.j2ee.filterchain.WrappedFilterChain.doFilter(WrappedFilterChain.java:134)
at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doNext(FusionReactorRequestHandler.java:764)
at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doHttpServletRequest(FusionReactorRequestHandler.java:344)
at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.doFusionRequest(FusionReactorRequestHandler.java:207)
at com.intergral.fusionreactor.j2ee.filter.FusionReactorRequestHandler.handle(FusionReactorRequestHandler.java:801)
at com.intergral.fusionreactor.j2ee.filter.FusionReactorCoreFilter.doFilter(FusionReactorCoreFilter.java:36)
at sun.reflect.GeneratedMethodAccessor90.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intergral.fusionreactor.j2ee.filterchain.WrappedFilterChain.doFilter(WrappedFilterChain.java:71)
at sun.reflect.GeneratedMethodAccessor89.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.intergral.fusionreactor.agent.filter.FusionReactorStaticFilter.doFilter(FusionReactorStaticFilter.java:54)
at com.intergral.fusionreactor.agent.pointcuts.NewFilterChainPointCut$1.invoke(NewFilterChainPointCut.java:41)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.ajp.AjpProcessor.service(AjpProcessor.java:486)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:790)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1459)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1952
… 85 more

java.lang.ArrayIndexOutOfBoundsException
The error occurred in Unknown: Line 0
R
Referrer
domain/Management/ImageLibrary.cfm

Date/Time
03-Apr-19 10:09:51 AM
Stack Trace (click to expand)
lucee.runtime.exp.NativeException: java.lang.ArrayIndexOutOfBoundsException

Caused by: java.lang.ArrayIndexOutOfBoundsException

0 Likes

#4

thanks! does it happen with any image or just specific ones?

the next step would be to create a simplified test case with sample images and then file new bug over at https://luceeserver.atlassian.net/ including a link back to this post

0 Likes

#5

I have posted a bug here . https://luceeserver.atlassian.net/browse/LDEV-2228

thanks.

1 Like

#6

cheers, that’s an excellent bug report :slight_smile:

0 Likes

#7

Probably the best documented bug report I’ve ever read!

0 Likes

#8

Thanks guys, I just hope it can be fixed.

0 Likes

#9

Changed Image.java rotate function to:

	public void rotate(float x, float y, float angle, int interpolation) throws ExpressionException {
		x = 0F;
		y = 0F;
		
		angle = (float) Math.toRadians(angle);
		Interpolation interp = Interpolation.getInstance(0);
		if (INTERPOLATION_BICUBIC==interpolation)	interp = Interpolation.getInstance(1);
		else if (INTERPOLATION_BILINEAR==interpolation)		interp = Interpolation.getInstance(2);
    	
		ParameterBlock params = new ParameterBlock();
		params.addSource(image());
		params.add(x);
		params.add(y);
		params.add(angle);
		params.add(interp);
		params.add(new double[] { 0.0 });
		image(JAI.create("rotate", params).getAsBufferedImage());
    }

Questions;

  1. Why is there and X and Y origin in this function? Since it expands the image on rotation it doesn’t matter. I force to 0F to fix a image problem when passing decimals and ArrayIndexOutOfBoundsException if you enter the exact height for Y.

  2. What is the _rotate function used with?

0 Likes