Cfimage

Using CFIMAGE to create a watermark

Continuing my week off playing around with cfimage, I am thinking this is fast becoming my favorite new feature in Coldfusion 8. This morning I was thinking it would be cool if Coldfusion could watermark images for me. After about 30mins playing around I came up with this.

<cfimage source=“img_2566.jpg” name=“image”>
<cfimage source=“watermark.png” name=“watermark”>
<cfset ImagePaste(image, watermark, 0, 0)>
<cfimage source=“#image#” action=“writeToBrowser” format=“jpg”>

First 2 lines I basically give both images a name. The reason the watermark is a png is I want to have the ability to use alpha channels. Next line I paste the watermark onto the image at 0x and 0y. I cheated and created the images the same size, but you could easily read the image info get the size then calculate where you want the watermark to be. The last line writes the image to the browser in the format of a jpeg. You can check it out in action at my CFwatermark page.

Using cfimage to create thumbnails

I have been playing around with the new cfimage tag in coldfusion 8. I am very impressed with the resize capability. Coldfusion 8 seemed to do a great job resizing my images into thumbnails. I created a tutorial here.

Here is a little bit of code to create thumbnails.


<cfimage action=“info” structname=“imagetemp” source=“Path to your image”>
<cfset x=min(150/imagetemp.width, 113/imagetemp.height)>
<cfset newwidth = x*imagetemp.width>
<cfset newheight = x*imagetemp.height>
<cfimage action=“resize” source=“#Path to your image#” width=“#newwidth#” height=“#newheight#” destination=“#thumbnail destination#”>

Update: My Using CFIMAGE to Generate Thumbnails tutorial was published at learncf.com

No Older Posts →
← No Newer Posts