Leave That Thing Alone Blog

ColdFusion Admin Presentation at October Sacramento User Group Meeting

Join SacCFUG Tuesday October 14th for an "Introducing the ColdFusion Administrator" presentation by Jose Gomez.

For more information and directions visit www.saccfug.com

CFImage Presentation Files

I have posted the "Image Manipulation with ColdFusion 8" presentation files for the September 17th 2008 BACFUG meeting.

There are two different ColdFusion folders in the zip file. The first is a is a collection of example cfm files that demonstrates the cfimage tag and the different image functions. The second is a sample application that demonstrates some of the things ColdFusion can do with your digital photos.

CFImage Presentation Files

ColdFusion 8 Image Presentation at Bay Area ColdFusion User Group

Next Wednesday September 17th I'll be presenting "Image Manipulation with ColdFusion 8" at the Bay Area ColdFusion User Group.

The presentation will start off by going over CFImage and the image tags that were introduced in CF8, in code we'll walk through examples of all the different functionalities. Next we'll move into some more advanced examples of how to get the image tags to do some neat effects, then briefly get into leveraging available Java libraries (AWT, JAI) to do some fun image stuff. Finally we will walk through an demo application that pulls all of CF8's image abilities together to create an image library for your digital photos that indexes, thumbnails, display camera details, rotates, and even allows search by color.

I will have example code posted next week before the presentation.

More details on the meeting location, RSVP, and Connect URL:
http://bacfug.org/index.cfm?event=showMeeting&meetingID=144AB637-20ED-7D0A-C0162EBEEC9647F1

Sava CMS at Sacramento ColdFusion User Group August 12th

Join SacCFUG Tuesday August 12 and hear Blue River Interactive Group talk about Sava an Open Source ColdFusion content management system.

Blue River will also be talking about their use of Railo an alternative engine for ColdFusion.

For more information and directions visit www.saccfug.com

Introduction to CFCs at Sacramento ColdFusion User Group July 8th

Join SacCFUG Tuesday July 8th for a great presentation by Nolan Erck on ColdFusion Components. If you are new to CFCs or just want to brush up on your CFC skills this will be a great presentation for you.

Visit the SacCFUG website for more details and meeting location info.

Sacramento ColdFusion User Group Meets June 10th

The Sacramento ColdFusion User Group is meeting Tuesday June 10th at 6:30pm, this month's topic will be code generation from UML. Please visit the SacCFUG website for more details.

SacCFUG is also happy to announce we have a new sponsor Clear Capital. Our monthly meetings will now be help at Clear Capital's office. Please see the meeting location page for the address and map.

One last note, SacCFUG has moved to a new email list you can subscribe here.

Using Exif Orientation to Rotate Digital Photos with ColdFusion

Here's a ColdFusion 8 function to rotate digital photographs via Exif 'orientation'. This function will accept a cfimage or a filename and return a rotated/flipped (if needed) image in cfimage format.

With ColdFusion 8's 'ImageGetEXIFMetadata' tag you can get the 'orientation' of a digital photograph. The 'orientation' value indicates if the camera was held/rotated landscape, upside down, portrait with right on the top, etc.

What makes this a bit more difficult is that there are 8 different orientation possibilities and the 'orientation' value can be a number or comma separated text. For example value 1== 'top, left side'. Full exif 'orientation' details here.


Example usages of imageExifOrientationRotate:


<!--- specify image via filename --->
<cfset myImage = imageExifOrientationRotate('IMG_3087.jpg') />
<!--- resize --->
<cfset imageResize(myImage,"200","") />
<!--- display --->
<cfimage action="writeToBrowser" source="#myImage#" />

or


<!--- read image --->
<cfimage action="read" source="IMG_3087.jpg" name="myImage" />
<!--- specify image via cfimage --->
<cfset myImage = imageExifOrientationRotate(myImage) />
<!--- resize --->
<cfset imageResize(myImage,"200","") />
<!--- display --->
<cfimage action="writeToBrowser" source="#myImage#" />

View imageExifOrientationRotate function:

Opening/Viewing multipage TIFFs with ColdFusion 8

Here's a quick example of how to open and/or view a multipage TIFF with ColdFusion 8. This example requires no external Java libraries.

The first step is to open the multi-page tiff and using the JAI ImageCodec we're able to determine the number of pages in that tif and create an array of the pages.


<cfscript>
    //set TIFF file name

    tifFileName = expandpath('samples\patent.tif');
    //create FileSeekableStream

    ss = createObject("Java","com.sun.media.jai.codec.FileSeekableStream").init(tifFileName);
    //create JAI ImageDecoder

    decoder = createObject("Java","com.sun.media.jai.codec.ImageCodec").createImageDecoder("tiff", ss, JavaCast("null",""));
    //create array

    tifPageArray = arrayNew(1);
    //loop through pages of tiff add to array

    for (i=0;i
<decoder.getNumPages();i++) {
        //add each to array (com.sun.media.jai.codecimpl.TIFFImage)

        tifPageArray[i+1] = decoder.decodeAsRenderedImage(i);
    }
</cfscript>

At this point we have array of tiff images (of type com.sun.media.jai.codecimpl.TIFFImage). Based on your needs your code will probably need to change after this. To be able to easliy 'use' these TIFF pages in ColdFusion we need to convert them to the cfimage format. One of the great features about the ColdFusion 'imageNew' tag is that it accepts BufferedImage as an input

So to move from TIFF to cfimage we do this:
TIFF -> PlanarImage -> BufferedImage -> cfimage

Here's some code to loop though all the pages and write a JPG for each page in the mulitpage tiff:


<cfscript>
    //loop through all tiff pages

    for (i=0;i
<decoder.getNumPages();i++) {
        //create PlanarImage

        pImg = createObject("Java","javax.media.jai.PlanarImage").wrapRenderedImage(tifPageArray[i+1]);
        //get buffered image

        bufferedImage = pImg.getAsBufferedImage();
        //use CF image tage to create CF image from bufferedImage

        myImage = imageNew(bufferedImage);
        //write image

        imageWrite(myImage,"page#i+1#.jpg");
    }
</cfscript>


You may want to alter the code above as writing TIFF pages to JPGs might not be what you need. After 'imageNew(bufferedImage)' we have a cfimage so you are able to do any ColdFusion 8 image function on the TIFF page.

Update:
Multi-Page Tiff support has now been added to ImageUtils

ColdFusion and Miro port 8500 conflict

Hopefully this post will save someone some grief. I have been having problems on my local development ColdFusion server where ColdFusion would just randomly stop responding to requests to http://localhost:8500 . I couldn't figure out a pattern.

finally I realized that this would happen when I was running Miro. Turns out Miro by default uses ports 8500-8600 for torrents and my dev CF server was using port 8500...

To fix this problem change the ports that Miro uses, go to 'File' - 'Options' - 'Downloads' tab and change the port(s) settings under the BitTorrent section.

CFCPhotoBlog Version 1.0

Version 1.0 of CFCPhotoBlog has finally been released...

Here are the main new features:

  • Photo's location linked to photo location thumbnail page display
  • Photo's category(s) now linked to category thumbnail page display
  • Added photo thumbnails to RSS feed
  • 2 new basic styles/skins added
  • New skins are text based support any width/height photo and better i18n support
  • An 'About' page added
  • Ability to display photo details by default on main photo display page
  • Added end images to bottom tabs to allow for easier tab add/remove (in default skin)

It has been really hard to find time to work on this starting the new job, but occasionally when I take the train to SF I get a bit of time to knock out a couple things. I will be working on the next version which I hope to add color indexing/searching and take advantage of some of the new CF8 image features. Hopefully it wont take another year and a half to get to version 2.0...

I'd like to thank those people who have sent in feature requests, sorry if I didn't include yours. I haven't had time to get to all of them, but please keep sending them.

This project is now on riaforge so if you have feature requests please visit the forums.

CFCPhotoBlog project page

More Entries