The pixel density of an image can be read or set with csImageLite. The property is DPI and it is always measured in dots per
inch. The functions DPMToDPI and DPIToDPM are available for converting to and from metric. There are two properties, XDPI and
The following code fragment loads an image and displays the pixel density.
Image.ReadFile "c:\images\photo.jpg"
Response.Write Image.DPI
The next fragment sets the DPI to 100
Image.ReadFile "c:\images\old.jpg"
Image.XDPI = 100
Image.YDPI = 100
Image.WriteFile "c:\images\new.jpg"
Not all formats store a pixel density value and this includes GIF. Some image editing software will show a value for DPI when opening one of these images but they are only selecting a default. The GIF format does not have anywhere to store this value. csImageLite can read and write pixel density in PNG images but this is an extension to the format that not all software supports.
© Chestysoft, 2024.
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.