ImageCopy() result wont be processed by ImageResize()

Hi there, happy to land here and happy to use Lucee for the first time, was a hell of a journey to setup my first linux server. And it was worth it, my app got a gain of like 3000% for some of the calculations involved (images manipulations).

But while porting the app,from ACF to LCF, I encountered an issue I’m struggling with:

<cfset myImage=ImageNew(arguments.backgroundImage)> 
<cfset ImageResize(myImage,33,33,'highestQuality',1)> --> OK!
<cfset drawnzone = ImageCopy(myImage,qr.x+arguments.w,qr.y+arguments.w,qr.w,qr.w)>
<cfset ImageResize(drawnzone,33,33,'highestQuality',1)> --> ERROR

I import in a function a PNG image --> MyImage is set with it
If I try resizing it, no issues.
Then I’m able to extract a rectangle of it in ‘drawzone’. dumping it shows the very same information for both ‘in memory’ pictures except of course firn height and width. And both images display properly in the dump.
But if I try to apply the same resizing line to the ‘copy’, I get this:

Lucee 5.3.2.77 Error (java.lang.IllegalArgumentException)
Message	Unknown image type 0
Stacktrace	The Error Occurred in
/var/www/html/qrcodebox/qrcode.cfc: line 274 
272: <cfdump var="#ImageInfo(drawnzone)#">
273: </cfoutput>
274: <cfset ImageResize(drawnzone,arraylen(rows)*1,arraylen(rows)*1,'nearest',1)>	<cfabort>
275: <!--- MODERATE ACCURACY OF THE DETECTION WITH AN ImagePaste --->
276: <cfset ImageResize(drawnzone2,arraylen(rows)*1,arraylen(rows)*1,'highestQuality',1)>

Java Stacktrace	lucee.runtime.exp.NativeException: Unknown image type 0
 	at java.desktop/java.awt.image.BufferedImage.(BufferedImage.java:501)
 	at org.lucee.extension.image.Image.resizeImage(Image.java:1271)
 	at org.lucee.extension.image.Image.resize(Image.java:1314)
 	at org.lucee.extension.image.Image.resize(Image.java:1257)
 	at org.lucee.extension.image.functions.ImageResize.call(ImageResize.java:63)
 	at org.lucee.extension.image.functions.ImageResize.invoke(ImageResize.java:69)
 	at lucee.runtime.functions.FunctionHandlerPool.invoke(FunctionHandlerPool.java:39)
 	at qrcode_cfc$cf.udfCall(/qrcode.cfc:274)
 	at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106)
 	at lucee.runtime.type.UDFImpl._call(UDFImpl.java:342)
 	at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:205)
 	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:683)
 	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:578)
 	at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1946)
 	at lucee.runtime.ComponentSpecificAccess.callWithNamedValues(ComponentSpecificAccess.java:156)
 	at lucee.runtime.ComponentPageImpl.callWDDX(ComponentPageImpl.java:629)
 	at lucee.runtime.ComponentPageImpl.call(ComponentPageImpl.java:189)
 	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:942)
 	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:834)
 	at lucee.runtime.listener.ClassicAppListener._onRequest(ClassicAppListener.java:64)
 	at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:43)
 	at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2409)
 	at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2399)
 	at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2374)
 	at lucee.runtime.engine.Request.exe(Request.java:43)
 	at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1037)
 	at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:983)
 	at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
 	at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
 	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:53)
 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
 	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
 	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
 	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1839)
 	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 	at java.base/java.lang.Thread.run(Thread.java:834)
 Caused by: java.lang.IllegalArgumentException: Unknown image type 0
 	... 51 more
 
Timestamp	8/7/19 11:54:42 PM UTC

I read in many places that this bug (?) persist in the java library but found no workaround for LCF. Any idea (I could save and reload the picture but that goes against the idea of solving the issue and also it definitly goes against the great performance :slight_smile:

Thanks!

Firstly, great bug report!

Which version of the image extension are you running?

HI Zac,

Well, excellent question. And thanks!

I moved back from the default installed snapshot to v 1.0.0.21 stable but I’m not sure the first error I encountered before that action was the same one, so, I need to check and get back to you :blush:

Well…With 1.0.0.24 it is going through :slight_smile: So, somehow this was addressed already since the last stable one …

The original error is back though, so I’ll paste it, but before, I’d say I probably need to try replacing cfimage write by a simple cffile write…(Mmm, scratch that.) Anyway, here it is:

Lucee 5.3.2.77 Error (java.io.IOException)
Message	FileStore The specified format has no associated registered ImageCodec.
Stacktrace	The Error Occurred in
/var/www/html/qrcodebox/qrcode.cfc: line 360 
358: <!--- <cfset file.g.path="files/0/"><cfset file.g.name="#CreateUUID()#.png"> --->
359: <!--- <cfset storeFile(file.a.name,file.a.path,1)> --->
360: <cfimage source="#myImage#" action="write" destination="#file.a.path##file.a.name#" overwrite="yes"> 
361: <cfset fileSetAccessMode("#file.a.path##file.a.name#", "777")>
362: <cfimage source="#IsolatedDrawingZone#" action="write" destination="#file.b.path##file.b.name#" overwrite="yes"> 

Java Stacktrace	lucee.runtime.exp.NativeException: FileStore The specified format has no associated registered ImageCodec.
 	at javax.media.jai.JAI.createNS(JAI.java:1091)
 	at javax.media.jai.JAI.create(JAI.java:977)
 	at javax.media.jai.JAI.create(JAI.java:1625)
 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
 	at org.lucee.extension.image.JAIUtil.create(JAIUtil.java:144)
 	at org.lucee.extension.image.JAIUtil.write(JAIUtil.java:106)
 	at org.lucee.extension.image.Image.writeOut(Image.java:1001)
 	at org.lucee.extension.image.Image.writeOut(Image.java:972)
 	at org.lucee.extension.image.tag.Image.doActionWrite(Image.java:422)
 	at org.lucee.extension.image.tag.Image.doStartTag(Image.java:285)
 	at qrcode_cfc$cf.udfCall(/qrcode.cfc:360)
 	at lucee.runtime.type.UDFImpl.implementation(UDFImpl.java:106)
 	at lucee.runtime.type.UDFImpl._call(UDFImpl.java:342)
 	at lucee.runtime.type.UDFImpl.callWithNamedValues(UDFImpl.java:205)
 	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:683)
 	at lucee.runtime.ComponentImpl._call(ComponentImpl.java:578)
 	at lucee.runtime.ComponentImpl.callWithNamedValues(ComponentImpl.java:1946)
 	at lucee.runtime.ComponentSpecificAccess.callWithNamedValues(ComponentSpecificAccess.java:156)
 	at lucee.runtime.ComponentPageImpl.callWDDX(ComponentPageImpl.java:629)
 	at lucee.runtime.ComponentPageImpl.call(ComponentPageImpl.java:189)
 	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:942)
 	at lucee.runtime.PageContextImpl._doInclude(PageContextImpl.java:834)
 	at lucee.runtime.listener.ClassicAppListener._onRequest(ClassicAppListener.java:64)
 	at lucee.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:43)
 	at lucee.runtime.PageContextImpl.execute(PageContextImpl.java:2409)
 	at lucee.runtime.PageContextImpl._execute(PageContextImpl.java:2399)
 	at lucee.runtime.PageContextImpl.executeCFML(PageContextImpl.java:2374)
 	at lucee.runtime.engine.Request.exe(Request.java:43)
 	at lucee.runtime.engine.CFMLEngineImpl._service(CFMLEngineImpl.java:1037)
 	at lucee.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:983)
 	at lucee.loader.engine.CFMLEngineWrapper.serviceCFML(CFMLEngineWrapper.java:97)
 	at lucee.loader.servlet.CFMLServlet.service(CFMLServlet.java:51)
 	at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
 	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:53)
 	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
 	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
 	at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:200)
 	at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
 	at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490)
 	at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
 	at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
 	at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
 	at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
 	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
 	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
 	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:836)
 	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1839)
 	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
 	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
 	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
 	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
 	at java.base/java.lang.Thread.run(Thread.java:834)
 Caused by: java.io.IOException: FileStore The specified format has no associated registered ImageCodec.
 	... 57 more
 
Timestamp	8/8/19 2:25:48 AM UTC

I tryed adding format=“jpeg”, jpg, png, no luck neither, same error, f.e:

<cfimage source="#myImage#" format="png" action="write" destination="#file.a.path##file.a.name#" overwrite="yes"> 

Dumping the image before saving it (and failing) gives this:

colormodel	
Struct
Entries: 12
alpha_channel_support	
boolean	false
alpha_premultiplied	
boolean	false
bits_component	
Array
1	
number	8
2	
number	8
3	
number	8
bits_component_1	
number	8
bits_component_2	
number	8
bits_component_3	
number	8
colormodel_type	
string	ComponentColorModel
colorspace	
string	Any of the family of RGB color spaces
num_color_components	
number	3
num_components	
number	3
pixel_size	
number	24
transparency	
string	OPAQUE
height	
number	604
metadata	
Struct
Chroma	
Struct
BlackIsZero	
string	TRUE
ColorSpaceType	
Struct
name	
string	RGB
NumChannels	
string	3
Compression	
Struct
CompressionTypeName	
string	deflate
Lossless	
string	TRUE
NumProgressiveScans	
string	1
Data	
Struct
BitsPerSample	
string	8 8 8
PlanarConfiguration	
string	PixelInterleaved
SampleFormat	
string	UnsignedIntegral
Dimension	
Struct
ImageOrientation	
string	Normal
PixelAspectRatio	
string	1.0
pHYs	
Struct
pixelsPerUnitXAxis	
string	1
pixelsPerUnitYAxis	
string	1
unitSpecifier	
string	unknown
Transparency	![a|690x460](upload://acpq7dKdfXjALo6UWxaJznpnA7C.jpeg) 
Struct
Alpha	
string	none
source	
string	/var/www/html/qrcodebox/files/uploads/6F1C808B-B376-451A-8911F842E32CF882_b071f62d-b08e-4dd5-aa1c-0ccaad9ad6f6_0_RESIZED.png
width	
number	906

And look like attached (after a Qrcode has been added to it):

To bad I cannot save it except by hacking the dump :-)))

I’ve checked this in lucee 5.3.2.77 and 5.3.4.23 & But I can’t able to reproduce any error while resizing an image after image copy() process. Could you please check with below test file and what I’m missing in this case, Because image resize is working fine for me. And also I’m checking with image extension 1.0.0.21 and 1.0.0.24 versions. But, no luck to reproduce.

test.zip (321 Bytes)

which jvm are you using… not all jvm’s are quite the same

Version Lucee 5.3.2.77


Version Name Gelert
Release date May 27, 2019 Remote IP 127.0.0.1


Servlet Container Apache Tomcat/9.0.20
Java 11.0.3 (AdoptOpenJDK) 64bit
OS Linux (3.10.0-957.27.2.el7.x86_64) 64bit
Architecture 64bit

Thanks for your time @cfmitrah (& @Zac_Spitzer!),

Here is your test file, it work with both your and my file. But it I try to save it as jpg or jpeg it fails with the same message:

FileStore The specified format has no associated registered ImageCodec.

If though if I’d try with .png, I’ll get a small step further:

FileStore IOException encountered in file creation test: Permission denied

I did not expect that, because file upload was fine, but this is a different folder, so I tested after propagating 775 to files/0 folder… and it fixed it.

So in my case, “FileStore The specified format has no associated registered ImageCodec.” really means
FileStore IOException encountered in file creation test: Permission denied”. Case closed. With many thanks :slight_smile:

https://qrcodebox.com/test.cfm

Damn, thanks to you I’ve got my first app adjusted (only permissions stuff) and moved under Linux/Lucee, feel free to play with translucid qrcodes ;-):

https://qrcodebox.com

My own reward to @Zac_Spitzer & @cfmitrah :slight_smile:

1 Like

thanks!

i think Lucee should be returning an error message which isn’t so cryptic.

such permissions problems can happen and developers get frustrated wasting time trying to track down such a simple problem…