Writing image after using imageGreyScale throws error "Metadata components != number of destination bands"

Description

*strong text*Using the example code + image found here: www.railodeveloper.com/jira/railo-imagegrayscale-bug.zip
I get an error "Metadata components != number of destination bands".
When line 3 is removed (the imageGrayScale function), the error does not occur. When the file is not written to disk on line 4, the error does not occur as well.
The example code is:

<cfset imgfile = "testimagebug.jpg" /> <cfimage source="#imgfile#" name="myImage" /> <cfset imageGrayscale(myImage) /> <cfimage action="WRITE" source="#myImage#" destination="#imgfile#_grayscale.jpg" overwrite="yes" /> done

I have checked this with multiple images, on both windows and mac.

Stack trace: Metadata components != number of destination bands at com.sun.imageio.plugins.jpeg.JPEGImageWriter.checkSOFBands(JPEGImageWriter.java:1279):1279 at com.sun.imageio.plugins.jpeg.JPEGImageWriter.writeOnThread(JPEGImageWriter.java:694):694 at com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:339):339 at railo.runtime.img.Image._writeOut(Image.java:937):937 at railo.runtime.img.Image._writeOut(Image.java:896):896 at railo.runtime.img.Image.writeOut(Image.java:857):857 at railo.runtime.img.Image.writeOut(Image.java:835):835 at railo.runtime.tag.Image.doActionWrite(Image.java:484):484 at railo.runtime.tag.Image.doStartTag(Image.java:332):332 at railo_imagegrayscale_bug864.testimagebug_cfm$cf.call(/developing/meuk/railo-imagegrayscale-bug/testimagebug.cfm:4):4 at railo.runtime.PageContextImpl.doInclude(PageContextImpl.java:788):788 at railo.runtime.listener.ClassicAppListener._onRequest(ClassicAppListener.java:36):36 at railo.runtime.listener.MixedAppListener.onRequest(MixedAppListener.java:24):24 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2143):2143 at railo.runtime.PageContextImpl.execute(PageContextImpl.java:2110):2110 at railo.runtime.engine.CFMLEngineImpl.serviceCFML(CFMLEngineImpl.java:313):313 at railo.loader.servlet.CFMLServlet.service(CFMLServlet.java:29):29 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717):717 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290):290 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206):206 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233):233 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191):191 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127):127 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102):102 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109):109 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298):298 at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:190):190 at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:291):291 at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:769):769 at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:698):698 at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:891):891 at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:690):690 at java.lang.Thread.run(Thread.java:680):680

Environment

None

Attachments

1
  • 03 Nov 2015, 06:47 pm

Activity

Pothys - MitrahSoft 27 April 2020 at 09:14

I've checked this ticket. The issue was fixed. So, I updated a version of lucee and image versions too.
I close the ticket.

Andrew Dixon 3 November 2015 at 18:50

Originally raised for Railo on ticket RAILO-1849 (https://issues.jboss.org/browse/RAILO-1849), here are the comments from that ticket:

Tjarko Rikkerink added a comment - 15/Aug/12 9:12 AM
I do get the same error in version Railo 3.3.4.003 final

John Whish added a comment - 03/Dec/12 4:43 AM - edited
just seen this on Railo 3.3.4.003 final on two different production servers.
Unlike Paul, I'm just using ImageResize followed by <cfimage source="#objImageLarge#" action="write" destination="#variables.ExpandedImagepathLarge##attributes.product_imagelarge#" overwrite="yes" quality="1" />
The file being uploaded was a JPG, but I'm afraid I don't have it to reproduce.

Michael Hnat added a comment - 14/Feb/14 8:58 AM
This bug ist stiil open and in my project it is some kind of showstopper right now.
This is my Code:

vImg = imageRead("Flag_DE.png"); imageScaleToFit(vImg,100,100,"hermite"); ImageWrite(vImg,"/thumbs/Flag_DE.jpg"); the problem doesn't exist when writing it to a png again: ImageWrite(vImg,"/thumbs/Flag_DE.png");

I'll try to add the picture that causes my error.

Michael Hnat added a comment - 14/Feb/14 8:58 AM
This is the file that causes my error. Hope it helps finding the problem.

Luis Majano added a comment - 09/May/14 6:28 PM
Any updates on this bug.

Denny Valliant added a comment - 16/May/14 10:19 PM
My comment on #2189 may be related.
https://issues.jboss.org/browse/RAILO-2189

Jean-Francois Vienneau added a comment - 11/Aug/15 4:08 PM
I was able to fix this issue using this function 'ImageGetBufferedImage' I'd suggest you go see Ben's page on the function.
http://www.bennadel.com/blog/766-learning-coldfusion-8-cfimage-part-i-reading-and-writing-images.htm
Basically here is how you fix it:

var img1Obj = ImageNew(img1Path); var img2Obj = ImageNew(ImageGetBufferedImage( img1Obj ));

And then use Img2Obj for your writting.
Hope that helps!

Fixed

Details

Assignee

Reporter

Priority

Labels

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Affects versions

Created 3 November 2015 at 18:47
Updated 20 February 2022 at 15:23
Resolved 27 April 2020 at 09:16