CFX_pureImagev1.002/April/2004© Claude Schnéegans |
|---|
| DESCRIPTION |
|---|
Most Image management software and hardware (cameras) produce files that embed information about creation date and method. This information, albeit useful in some circumstances, is useless for display in a browser.
The average size of this data varies from 5 to 10k, and can even grow up to 58k, as I personnally found in Photo Shop files! If you have a bunch of files which contain 5k images (ie Id photos), they will all take more than 50k each, a total of 10 times the normal size!. If you have say 1000 of them, this means a loss of 50 megs on your server disk. If you have 10000 of them, you may be paying your site hosting company for half a Gig for nothing! Many times the price of this tag.
Although most software have a function to remove this information, it is generally hidden some where in the settings and few people actually use it or are even aware of their existence.
This very simple tag then just reads a JPEG file and rewrites a pure image in its simpler possible form.
notes:
1. The tag supports both the standard JPEG format (.JPG) and the EXIF format (.JPE), but not the JPEG 2000 format.
2. The tag can be applied to any file. If a standard JPEG format is not recognized, the file is left untouched.
Important: The JPEG code is never decompressed and recompressed, so the operation is performed with absolutely no quality loss.
| NOTE |
|---|
| INSTALLATION |
|---|
You do this by going to the "CFX Tags" tab in the administrator,
For more information refer to the ColdFusion documentation "Managing CFXs".
| SYNTAX |
|---|
<CFX_pureImage FILE="full path name of the file">
| RETURNED VARIABLES |
|---|
The tag sets the following variables in the calling program:
PI_originalSize = the original size of the file;
PI_newSize = the new size of the file;
PI_width = the width in pixels of the image;
PI_height = the height in pixels of the image;
In the case the file contains no superfluous information that can be removed, the file is only read, but the tab can still be used to read the width and height of the image. This tag may then replace any other tag used only to get this information. If the file is not a recognized JPEG format, all variables are returned set to 0.
| EXAMPLES |
|---|
<CFX_pureImage FILE="C:\Images\MyImage.jpg">
<CFSET Path=C:\Photos\">
<CFFILE ACTION="Upload"
FILEFIELD="File_Name"
DESTINATION="#Path#"
NAMECONFLICT="MakeUnique">
<CFSET FileName = Path & File.ServerFile>
<CFSET FileSize = File.FileSize>
<CFSET Path=C:\Photos\">
<CFFILE ACTION="Upload"
FILEFIELD="File_Name"
DESTINATION="#Path#"
NAMECONFLICT="MakeUnique">
<CFSET FileName = Path & File.ServerFile>
<CFX_pureImage FILE="#FileName#">
<CFSET FileSize = PI_newSize>
<CFSET Path=C:\Photos\">
<CFDIRECTORY
directory = "#path#"
name = "getFiles"
filter = "*.jp*">
<CFLOOP QUERY="getFiles">
<CFX_pureImage FILE="#path##name#">
<CFSET saved = PI_originalSize - PI_newSize>
<CFOUTPUT><P><B>#name#</B> : size = #PI_originalSize#
<BR>new size = #PI_newSize#
<BR>saved = #saved#
</CFOUTPUT>
</CFLOOP>