Valid values are fractions that range from 0 through 1 the lower the number, the lower the quality. Alias: colour. Alias: variable. Lucee supports only the system fonts that the JDK can recognize. If the destination file already exists, Lucee generates an error if the overwrite action is not set to yes. Border thickness in pixels.

Author:Vugul Tygorisar
Language:English (Spanish)
Published (Last):21 November 2013
PDF File Size:13.66 Mb
ePub File Size:15.86 Mb
Price:Free* [*Free Regsitration Required]

Finally, ColdFusion 8 has incorporated image manipulation directly into the ColdFusion tag and scripting language. These products, while excellent in quality, just meant adding one more level of complexity to any application that required server-side image manipulation.

Now, with CFImage and an abundance of image related functions, ColdFusion has done to image manipulation what it has done to most every other aspect of web applications development - it has made it simple. Due to the wide array of image functionality in ColdFusion 8, I am going to try and break this tutorial up into several small and management parts. The first part will cover basic reading and writing of images using CFImage and the related image manipulation functions.

But, before we get into that, let's just quickly touch upon these new features as a whole. ColdFusion 8 has given us CFImage. CFImage provides us with tag-based access to only a small subset of the image functionality including:.

In addition to the CFImage tag, ColdFusion has introduced dozens of new image manipulation functions including:. Most of you are not going to care about this one all that much, but for any of you that are interested in the underlying Java methods of the coldfusion.

Image object, I have listed them below skip past this if you have no idea what I am talking about. If you choose to use them, you do so at your own risk and discretion. String, int, int, coldfusion. Struct returns: void. PageContext returns: coldfusion. String, javax. PageContext returns: java. String, java. String returns: void. String, double returns: void. Object returns: void. For those of you who took a look at the underlying Java methods, you can see that there's a lot of stuff wrapped up in these image objects.

The ColdFusion 8 CFImage tag and the related image manipulation functions probably provide some sort of facade that wraps around the these underlying methods. For more information about what these do as they are undocumented , you might want to try exploring the java.

Ben Forta stated at the New York ColdFusion Users group that Adobe has built the ColdFusion image manipulation around this library, but that they have also greatly extended it to work around the limits that this library holds. One of the most exciting features of the new ColdFusion 8 image manipulation is large number of file formats that can be read in and written out.

These return comma-delimited lists of the file types that ColdFusion can deal with. Super sweet! I don't know how they handled that one since I thought Prodigy owned the patent on that or something silly , but it's good to see that we have a huge variety of image formats that we can read an write to. Now that we have the general overview of what kind of new and exciting image manipulation features are available in ColdFusion 8 and how many image types can be utilized, let's actually get into the meat of this part of the tutorial: reading and writing images.

To start with, let's examine reading images using the CFImage tag. When reading in an image, the source of the image can be any one of the following:. Did anyone else see "URL" and get mentally turned on? In the first example, we are using the CFImage tag in conjunction with an absolute path name to the image. This reads in color information, source value, and dimensions into a struct. Running the above code, we get the following CFDump output:. The other input types give a similar output, so I will not show the CFDump, however, I will walk through the code.

The next one on the list is the web-relative path:. It is not just important that the resultant data is image data, it is also important that the last thing in the URL be the file name. For example, using a url with this query string:. The com image format is not supported on this operating system. This will only work to direct image URL access. This seems like a bug to me as I would have assumed it was just doing a binary grab via CFHttp or something like that , but I guess there is more to it than I can understand.

I would rather it try to grab the resultant data and throw an exception if the read fails. This will work quite nicely. You can get the idea here that ColdFusion is really just doing some sort of ListLast type functionality on the URL to get the file extension. A bit of a hack, but it works if you need it to.

The next input type is a ColdFusion image object. We don't have to perform actions just on new images; we can perform them on existing image objects:. I am grouping these two together because I am sure what the difference really is.

To me, they are both binary objects I think. I don't generally deal with these sorts of objects:. The next input type is a Base64 encoded string. This doesn't mean the target file is a Base64 data text file - this means the actual input value is Base64 image data:.

I don't deal with Base64 encoded images all that often, but this seems like something that could be very useful when put into clever hands. When you read in an image in this fashion, the source attribute is empty. The Base64 data does not require headers to be used.

For all the above "Read" demos, we were really just getting the info about the image. If you want to actually read in the image into a ColdFusion variable in the form of the coldfusion. Image data type , use the action "READ":.

While this reads the image into memory, if you CFDump it out, you will get the same output as if you were dumping out the INFO action result. Now that we have covered the tag-based reading, let's examine reading in images using the new ColdFusion 8 image functions. To start with, let's take a look at ImageRead. When it comes to functions, if you want to read in Base64 image data, you have to use the ImageReadBase64 function:. In addition to these straight forward methods, ColdFusion 8 can also use the ImageNew function to read in images.

Like the methods and tags above, ImageNew can also take a variety of source types:. We have looked at most of these types above. The only one here that stands out is the Java buffered image. This is the object that the ColdFusion image is wrapped around and is exposed through the function ImageGetBufferedImage.

To demonstrate this, we can grab the buffered image of one image object and use it to instantiate a new image:. This kind of functionality can be super useful if you are interfacing with another Java component that handles image manipulation using the java. So that just about wraps up reading in image files. I know this post is waaaay to long, so let's quickly cover writing images. As with reading in images, writing them can be done both by using the CFImage tag as well as the image functions.

The CFImage tag makes writing files especially easy since the source attribute is so flexible. Here, we are going to read an image from a URL and save it to disk:. Notice that the destination path is not an absolute server path - it's a path relative to the current web page. Also notice that the destination image was a GIF file format. By default ColdFusion will throw an error if there are naming conflicts.

To overcome this, you can set the Overwrite attribute to true defaults to false - this will overwrite any existing files at the same name. Now, not only is it super easy to grab images, it is super easy to convert image types.

This also demonstrates our next mode of image writing: writing the image directly to the browser. Notice that to do this, I am specifying the source of the image the image object we created and the output format of JPG. Now, when I first saw this action, I had assumed it was working the same way CFContent worked, by streaming the file to the browser as the only returned content. However, WriteToBrowser actually returns the image inline to the page. If you look at the source of the page with the rendered inline image, you will see something like this:.

ColdFusion is actually writing your file to some sort of temporary image storage and then serving it up the way any other image or file would be served up.

But what is CFFileServlet? If I look in the root of my ColdFusion 8 test account, there is no such directory. This is some sort of public mapping, but realize this - this is not a ColdFusion request; this is an image file request. This makes me nervous. I think it's an awesome feature, but I am not sure I like have to rely on mappings and tying in with settings external to the ColdFusion application server. Storing an image to a temp directly and then serving is using the web server is going to be 10 times more efficient.

I would like to know more about how CFFileServlet works and specifically how often that directory is cleaned out. I don't want to start writing a lot of images to the browser only to find out that it is clogging up this temp directory. ImageWrite take three arguments potentially :.

Destination - The absolute or relative path name to which you are going to write the image. This argument is optional if the Source attribute of your image is available. So, for instance, if you read in the image locally via CFImage and then called ImageWrite without a destination, it would overwrite the original image based on the internal Source.



Configuring and Administering Adobe ColdFusion 9. Developing Adobe ColdFusion 9 Applications. Using the cfimage tag. Using the ImageNew function. Creating an image from a binary object. Creating images from BLOB data.


Converting images

Creates a ColdFusion image. Note: You can specify this tag's attributes in an attributeCollection attribute whose value is a structure. Specify the structure name in the attributeCollection attribute and use the tag's attribute names as structure keys. Border color.


Using The Quality Attribute With The CFImage WriteToBrowser Action

Tags Functions Contact Login. The action to take. Hexadecimal value or supported named color. For a hexadecimal value, use the form " xxxxxx" or "xxxxxx". Can be either a full physical path or a relative path see the URIDirectory attribute. Absolute or relative pathname where the image output is written. The image format is determined by the file extension.

Related Articles