Changing the image format in ASP with csImageLite

It is easy to use csImageLite to change the format of an image from one supported type to another. Simply load the image in the orignal format and then save or export using the new format.

The following code fragment loads a TIFF image and saves it as a JPEG.

Image.ReadFile "c:\images\photo.tif"
Image.WriteFile "c:\images\photo.jpg"

The next fragment loads the TIF and streams the image to the browser as a JPG. This is a common conversion because it allows a TIFF to be displayed in browsers that do not support the format.

Image.ReadFile "c:\images\photo.tif"
Response.ContentType = "image/jpeg"
Response.BinaryWrite Image.StreamToBrowser "jpg"

The above code assumes that an instance of csImageLite 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.

Image format conversions can sometimes lose information. For example converting PNG to JPG can lose transparency, and converting JPG to GIF can lose pixel density (DPI / Pixels per metre) as well as colour depth. csImageLite has no support for meta data, which can be stored within certain file types and this will also be lost during the conversion.

File formats supported by csImageLite are BMP, GIF, JPG, PNG, and TIF.


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.