Interesting and Technical problems solved and explained

Lucee - Extentions running cfimage in lambda

In the previouse article on CFML I provided a more indepth look at CFML in lambda. In this post we will explore how to install extentions so we can use functions such as cfimage of the AWS S3 extentions in cfml.

The demo url is:

You can try your own image as follows:

# jpeg, png, gif all should work{url}/{image}.jpg

This was actually much easier then expected, I thought at first I’d need to drop in some extra jars, or open the lucee lite jar and add the lex files to the extentions folder then zip it back up, but it was easier then that. Lucee extentions will be picked up and installed via envrioment variables. We easily have this in the SAM template so literally 1 line I had the extention installed:

          FELIX_CACHE_BUFSIZE: 16384
          LUCEE_EXTENSIONS: 'B737ABC4-D43F-4D91-8E8E973E37C40D1B;name=cfimage;version=,17AB52DE-B300-A94B-E058BD978511E39E;name=cfs3;version='

In the example abouve 2 extention are installed: Image extension and S3 Resource Extension

The ID comes from:, this is simple the ID of the extention, name is a name ( can be anything ) version is wel the version.


Here is some example code:


    cfheader( name="Content-Type", value="text/html" );

        imgUrl = url['img']
    // Download the image into a CFML image variable.
    // Get the mete data of the file
    // Maintain spect ratio.
    newWidth = 320;
    newHeight = (original.height/original.width) * newWidth;

    // resize the image
    // Deep copy the image, cfimage rotate rotates the original aswell as the output?  Meh, seams like an issue?
    copy = Duplicate(resized);
    writeOutput("<strong>Original Image:</strong><br/>" & resized & "<br/>");

    // Turn the image upside down
    writeOutput("<strong>Rotated Image:</strong><br/>" & upsideDownImage & "<br/>");

    // Covert to greyscale
    writeOutput("<strong>GreyScale Image:</strong><br/>" & copy);


Example output: Function

Loading the extention measn the startup time will take a bit of a hit. Perhaps there is a better way, I suspect the future would be a custom layer for lucee and that shoud enable us to pre-package extentions.