Converting an image to jpg on server

I reviewed Trouble converting png to jpg
But It seems to be occurring still or again.The below works, but if the file being written is a jpg, then it writes, but as a 0kb file. The image does not upload.
I can change my cfdocuments to use png, but was hoping to not have to do that .
Also, tried using convert and will create teh jpg, but still as 0kb.
Windows server 2016 Lucee 5.3.5.92

<cffunction name="submitSignature" access="remote" returntype="boolean">
        <cfargument name="signature" type="string" required="yes">
        <cfargument name="planned_shipment_skey" type="string" required="yes">
        <cfset image = imageReadBase64(arguments.signature)>
        <cfset destination = expandPath('../../../Attachments/signatures/') > 
       
    <!---    <cfimage
            action="convert"
            destination="#destination##planned_shipment_skey#.jpg"
            source="#image#"
            overwrite="yes"
            quality="0"
            >--->
        <cfimage
            action="write"
            destination="#destination##planned_shipment_skey#.png"
            source="#image#"
            overwrite="yes"
            quality="0"
            >

        <cfreturn true />

    </cffunction>    

are you running the latest version of the image extension?

@Zackster, just updated but Windows Server 2016 Lucee 5.3.5.92
Image Extension is 1.0.0.35
If I go to the file server and look at the image if it is a gif or jpg, it shows as 0KB file with nothing displaying.
If I use png the file displays properly. This is a signature that displays on a document.Using canvas to capture the signature.

what does <cfdump var=#imageInfo(image)#> show?

1 Like

can you file a bug in jira and attach the image?

Done
https://luceeserver.atlassian.net/browse/LDEV-2869

1 Like

Can you also attach the problematic src image file?

added both to JIRA, but here is the png. would not take the jpg, as it is blank

thanks for the sample, I had a play and got some stack traces which I attached to the bug.

You’re also using Java 11 OpenJdk?

11.0.3 (AdoptOpenJDK) 64bit

Apache Tomcat/9.0.34

Does anyone have a workaround in the meantime?
PNG’s while they do create, come out extremely light and have tried many variations. This will be a huge hold up in moving to lucee.

We actually figured out a work around for us.
Looping through and making sure the color was set to actual black and then saving as a jpg on client side instead of server side. Then when you upload to server in Lucee it does write as a jpg

for (i=3;i<iData.data.length;i+=4){
		//if the opacity is 0 change the color to white:
		if (iData.data[i] == 0) {
			iData.data[i-1]=255;
			iData.data[i-2]=255;
			iData.data[i-3]=255;
		}
		//Change opacity to 100% for everything:
		iData.data[i]=255;
	}
	this.canvas.hide();
	this.context.putImageData(iData,0,0);

	var dataString = this.canvas.get(0).toDataURL("image/jpeg");
	var index = dataString.indexOf( "," )+1;
	dataString = dataString.substring( index );