Image Manipulation in Coldfusion MX 6.1 – Issues and Workarounds

Hello readers.

Today I am going to post a quick but detailed overview of the job which I was onto since a couple of days. As it’s pretty obvious from the title that I am going to write some thing about image handling and manipulation in a coldfusion application. But very first I want to mention that as most of you would have knowledge that CF8 and CF9 do have built-in tag for image manipulation. Here I’ll not talk about CF8 or CF9 functionalities but I would do about CFMX6.x because the main purpose for third party image manipulation resources would really ease in the earlier versions of Coldfusion which never had a built-in support for image manipulation.

So the brief is that I had found and used a couple of third party tags for image manipulation on CFMX6.1. They all worked good. I am talking about tags, both the ones developed with C++ and the other ones developed with Java. But they were only good until I have to put them to manipulate BMP images…. Huh!!!! They all just refused to manipulate the images of format BMP. I got again to search some others, I did find as well. But again they didn’t work good with BMP Images unless I tested them on later versions of Coldfusion. Specifying this statement that they worked on later versions of Coldfusion but not on CFMX6.1.

I’ll just get to point that why it caused the issues on CFMX6.1 and how to work around it. But before, I would mention that the workaround will be good till you use an Image Manipulation custom tag, component or a library which are built with Java Native APIs. This will not fix the issue with the tags built with C++.

With Java, the issue is caused due to the earlier versions of JRE (Java Runtime Environment) on which the earlier versions of Coldfusions were relying. As CFMX6.1 was initially on JRE 1.4.2 and unfortunately JRE 1.4.2 was not supporting BMP plug-ins. SUN started to put built-in support for more formats of images in later versions of Java. But fortunately SUN started the project JAI (Java Advanced Imaging) also to support the earlier versions of Java which were not optimized fully with image manipulation. And they do release the JAI Libraries to add in your earlier versions of Java.

But specifically for our purpose here we don’t need the whole APIs but only the “JAI-ImageIO” (download links at bottom). You just need to download the libraries and add into your CFMX6.1’s run-time directory as follows.

%COLDFUSION_INSTALL_DIRECTORY%\runtime\lib\jai_imageio.jar

“jai_imageio.jar” is the jar file which should be found in the downloaded archive and you have to place in the directory as showed above. You will surely need to restart the Coldfusion Application service. And done! your tag or component(built to work with Java APIs) should work good now with almost all types of images.

Additionally for my basic requirement of resizing specifically BMP image files or any other image, I did make my own CF Component with a re-size functionality which directly uses Java APIs to get the job done. I also wrote a custom tag to make it more developer friendly. I named it the “JImage” (in which J stands for Java). The tag actually works with the component inside. But you can work with the tag or with the component depending on your ease of use.

I really hope this post will be use full and I’ll welcome your comments and feedback on this.

Thank you for reading.

References
JImage Tag/Component (downloadonline demo)
JavaTM Advanced Imaging Image I/O Tools Binary Builds (https://jai-imageio.dev.java.net/binary-builds.html)