Wednesday, May 7, 2008

ColdFusion 8.0.1 - New update to Patch for CFImage and Image functions

Good news. Adobe released an update to the Patch for CFImage and Image functions in ColdFusion 8.0.1 today (05/07/2008). So far it seems to have resolved several issues mentioned in a previous entry. So if you have been experiencing similar errors, or continued problems with locked image files, consider applying the updated patch.

...Read More

Tuesday, May 6, 2008

ColdFusion 8.0.1: Post updater Image Function Issues

Once again, adobe forum member hans blix seems to be the unfortunate winner in the highly unofficial "Image function issue contest" ;-) He posted about two exceptions that seem to occur with certain JPEG images: Quantization table 0x02 was not defined and Missing Huffman code table entry . Another related issue was that image files seemed to be locked on error.

The good news is a hotfix should be released soon according to Kiran Sakhare of Adobe. So keep an eye out for it.


UPDATE: The hotfix was released on 05/07/2008. See Patch for CFImage and Image functions in ColdFusion 8.0.1



Note: The image hotfix was updated on 08/15/2008. The file name is exactly the same as the one released on 05/07/2008. So check the file timestamp to make sure you have the latest fix.


In the mean time, thanks to a posting by another forum member markthickpaddy, we came up with the following as a work-around. It is a combination of code from myself, markthickpaddy, framework from Rick Root's great ImageCFC and a Tech Tip from sun.com.




<cffunction name="ImageWriteReplacement" returns="void" access="public" output="false">
<cfargument name="image" type="any" required="true" hint="ColdFusion image object to save">
<cfargument name="destination" type="string" required="true" hint="Absolute path where you want to save the file">
<cfargument name="quality" type="numeric" required="false" default="0.75"
hint="Image quality for jpg,jpeg images only. Fractional value between 0 and 1 (highest quality). Default is 0.75">

<cfset var Local = {} >

<cfset Local.extension = trim( listLast( arguments.destination, "." ) )>
<cfset Local.buffered = imageGetBufferedImage( arguments.image )>
<cfset Local.outFile = createObject("java", "java.io.File").init( arguments.destination )>
<cfset Local.imageIO = createObject("java", "javax.imageio.ImageIO")>

<!--- confirm there is at least one registered writer for this image "format" --->
<cfset Local.iter = Local.imageIO.getImageWritersByFormatName( Local.extension )>
<cfif Local.iter.hasNext()>
<cfset Local.writer = Local.iter.next()>
<cfelse>
<cfthrow message="No suitable image writers found for format: #Local.extension#">
</cfif>

<!--- If this is a JPEG file ... --->
<cfif listFindNoCase("jpg,jpeg", Local.extension)>
<!--- set the image quality --->
<cfset Local.param = Local.writer.getDefaultWriteParam()>
<cfset Local.param.setCompressionMode( Local.param.MODE_EXPLICIT )>
<cfset Local.param.setCompressionQuality( javacast("float", arguments.quality) )>

<!--- create a stream for the output image file --->
<cfset Local.outStream = createObject("java", "javax.imageio.stream.FileImageOutputStream").init( Local.outFile )>
<cfset Local.writer.setOutput( Local.outStream )>

<!--- convert the image to an IIOImage we can pass to the writer --->
<cfset Local.image = createObject("java", "javax.imageio.IIOImage").init( Local.buffered , javacast("null", ""), javacast("null", "") )>
<!--- save the image to disk and close the stream --->
<cfset Local.writer.write( javacast("null", ""), Local.image, Local.param)>
<cfset Local.outStream.close()>

<cfelse>
<cfset Local.imageIO.write( Local.buffered, Local.extension, Local.outFile )>
</cfif>

</cffunction>

...Read More

Wednesday, April 30, 2008

ColdFusion 8: Wrap and scale image text (Coming soon to a theatre near you)


Update November 16, 2009: Unfortunately, it looks like the RTF functionality is being moved to an incubator project:

http://www.mail-archive.com/itext-questions@lists.sourceforge.net/msg47892.html
http://www.mail-archive.com/itext-questions@lists.sourceforge.net/msg48015.html

So I took a hiatus from blogging for a while. Work has been a bit crazy. Seems like every time I think about blogging it is already time to stumble into bed, get some sleep and start the cycle all over again.

Anyway, in my scant spare time I have been batting around the idea of how to automatically scale wrapped text to fit a given area. It is still in the "rough" stages, but I have finally worked out a raw example that seems to be working .. so far. I say "so far" because those fonts are tricky devils. But I like a challenge. Now if only there were more hours in the day..

Since my brain has officially left the building for today, I will try and post the first draft code tomorrow or the day after. But for now here is a screen shot of the available options. Yes, the form is terribly bland but I was more interested in the image code behind it than creating a slick looking form ;-)

Later!


...Read More

Saturday, April 26, 2008

ColdFusion 8.0.1 Patch - Issue: Image files are locked after ImageResize

Recently an adobe forum member, that goes by the name hans blix, posted about a problem with deleting files that were manipulated with CF's image functions, under CF 8.0.1. The image files seemed to be locked and could not be deleted until ColdFusion was restarted.

In his case he was reading an image with <cfimage>, resizing it, then deleting the original file. Apparently, ImageResize() seemed to be locking the image file. So the call to delete the original image generated an exception:

ColdFusion could not delete the file <path to image file> for an unknown reason.


Fortunately, Ken Smith mentioned there is a patch for this issue. So if you are also encountering this problem, you can find the patch here: Patch for CFImage and Image functions in ColdFusion 8.0.1 (kb403411).


UPDATE: The image hotfix was updated on 08/15/2008. The file name is exactly the same as the one released on 05/07/2008. So check the file timestamp to make sure you have the latest fix.

...Read More

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Header image adapted from atomicjeep