This is an example of using the csImageFile component to view and edit JPEG meta data using Cold Fusion (on Windows servers only). You will need the csImageFile component installed on your server as well as the sample files, which can be downloaded below. We also have an ASP version of this example.
In this example we show how to read and edit the JPEG File Info properties of a single JPEG file. The file is hard coded into one of the scripts, so some extension work is necessary to convert this into a complete application for editing any file.
The sample files are listed below. The readme.txt file contains a description of what each file does and how to make the demo work.
|fileinfo.cfm||The starting page. This is where the JPG name is specified and the File Info is read from it and placed in a form.|
|update.cfm||This is the script that processes the form and saves the changes to the File Info properties.|
|test.jpg||A JPG file containing some meta data.|
|readme.txt||A description of the application.|
The files must all be put in the same directory, which must be web shared with permission to run scripts. The Internet Guest User must have Modify permission on the JPG image.
The HTML formatting is kept to a minimum. A table is used in fileinfo.cfm to keep the form items in line, but this should not make the script difficult to follow. The main complications are caused by the Keywords and Supplemental Categories properties because these are lists of strings stored as arrays. The Read Me file provides a full explanation.
You can edit the File Name in "fileinfo.cfm" to work with a different image. If you want to extend the application to be able to select an image you would need to add an extra page of your own to select the file name and then pass this name to "fileinfo.cfm".
In this example, the image is not loaded completely into csImageFile. The meta data is loaded using the ReadMetaData method and after editing it is saved back to the file using OverwriteMetaData. This can increase the speed when working with large files and it prevents degradation of the jpeg image when saving it again.
There are some working exmples in our live demonstration area.
For a full list of available Cold Fusion demos and tutorials for csImageFile - Click Here.
© Chestysoft, 2012.