Skip to main content
Ben Nadel at cf.Objective() 2013 (Bloomington, MN) with: Steven Neiland
Ben Nadel at cf.Objective() 2013 (Bloomington, MN) with: Steven Neiland

Image Paste Bug In Lucee CFML

By
Published in Comments (2)

Last week, in my post on rendering QR Code images with Zxing in ColdFusion, I had mentioned at the end of the post that I ran into issues in Lucee CFML with using a BufferedImage as the source to a ColdFusion image object. Yesterday, Zac Spitzer asked me to come up with an isolated reproduction of the issue. And, in doing so, I realized that my assessment was slightly off - it's not a BufferedImage issue, it's an imagePaste() issue. It seems that in Lucee CFML, once you paste one image into another, no subsequent drawing operations work (on that destination image).

Here's a production of the problem - it runs two tests: one without and then one with an imagePaste() operation. Each test attempts image drawing operations both before and after the paste operation.

<cfscript>

	// The only difference in the two tests is that one will perform imagePaste().
	tests = [ false, true ];

	results = tests.map(
		( doPaste ) => {

			var black = imageNew( "", 20,  20,  "rgb", "000000" );
			var white = imageNew( "", 100, 100, "rgb", "ffffff" );

			// Draw MAGENTA boxes BEFORE paste.
			white.setDrawingColor( "ff3366" );
			white.drawRect( 10, 10, 20, 20, true );
			white.drawRect( 30, 30, 20, 20, true );
			white.drawRect( 50, 50, 20, 20, true );
			white.drawRect( 70, 70, 20, 20, true );

			// Pasting one image into another seems to corrupt the destination image
			// (in Lucee CFML); and, prevents subsequent image manipulation operations.
			if ( doPaste ) {

				white.paste( black, 70, 10 );

			}

			// Draw CYAN boxes AFTER paste.
			white.setDrawingColor( "008b8b" );
			white.drawRect( 10, 40, 10, 10, true );
			white.drawRect( 30, 60, 10, 10, true );
			white.drawRect( 50, 80, 10, 10, true );

			return white;

		}
	);

</cfscript>
<cfoutput>

	<cfloop array="#results#" item="image" index="i">

		<div>
			<!--- Write the image to disk. --->
			<cfimage
				source="#image#"
				action="write"
				destination="#expandPath( './#i#.png' )#"
				overwrite="true"
			/>

			<!--- Render image we JUST wrote to disk. --->
			<img src="./#i#.png" />
			<cfdump var="#imageInfo( image )#" />
		</div>

	</cfloop>

</cfoutput>

If we run this ColdFusion code in Lucee CFML, we get the following output:

As you can see (in Lucee CFML), the cyan boxes are only drawn in the test in which the imagePaste() operation is not performed. Once we paste one image into another, the subsequent drawing operations appear to have no effect.

As a control, if we run the same ColdFusion code in Adobe ColdFusion 2025, we get the following output:

As you can see (in Adobe ColdFusion 2025), the cyan boxes are drawn regardless of whether or not the imagePaste() operation is performed.

Want to use code from this post? Check out the license.

Reader Comments

Post A Comment — I'd Love To Hear From You!

Post a Comment

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel