Some images contain an embedded colour profile (ICC Color Profile) which gives the viewing software information about how to display the colours. csImageFile can preserve this profile in JPG and TIF images, but it is not default behaviour. If an embedded profile must be preserved, the KeepICCProfile property must be set to true before reading the image.
The following code fragment loads a JPG image while keeping any embedded ICC profile. Then it resizes and saves the image.
<cfscript>
Image.KeepICCProfile = true
Image.ReadFile("c:\images\big.jpg");
Image.ResizeFit(300, 300);
Image.WriteFile("c:\images\small.jpg");
</cfscript>
The above code assumes that an instance of csImageFile has been created called "Image". When reading and writing files always use the full physical path and give the Internet Guest User account appropriate permissions to read, write or modify.
If the image does not contain an ICC profile, the code still runs. If the KeepICCProfile property is left with the default value of false, any ICC profile will be lost when the image is loaded. If the original image is saved in CMYK colour space the profile may become invalid as the new image is converted to RGB.
© Chestysoft, 2018.