Editing images containing ICC colour profiles in ASP using csImageFile

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 JPEG and TITF images, but it is not the 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.

Image.KeepICCProfile = true
Image.ReadFile "c:\images\big.jpg"
Image.ResizeFit 300, 300
Image.WriteFile "c:\images\small.jpg"

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.

By default the KeepICCProfile property is false and embedded colour profiles will be discarded. This is in line with our upgrade policy where we avoid changing the default behaviour when we add a new property.


This site uses cookies for functionality, traffic analysis and for targeted advertising. Click the Accept button to accept our Cookie Policy. The Cookie Policy page offers configuration for a reduced set of cookies for this site.