[Apache Sanselan] Retrieving Image Information using Sanselan

Apache Sanselan is a pure Java library for reading and Writing Image formats. It has recently graduated from Incubator and is now a proud member of Apache commons proper.

In this article we shall see how to get Image Information using Apache Sanselan.

Let’s see how the code looks

Most of the work is done in single line 🙂

getImageInfo() API returns the ImageInfo details. The toString() method of ImageInfo class prints the image information in a formatted fashion.

Running the program on one the images shipped with Sanselan source produced this output

Format Details: Jpeg/JFIF v.1.2

Bits Per Pixel: 24

Comments: 0

Format: JPEG

Format Name: JPEG (Joint Photographic Experts Group) Format

Compression Algorithm: JPEG

Height: 225

MimeType: image/jpeg

Number Of Images: 1

Physical Height Dpi: 72

Physical Height Inch: 3.125

Physical Width Dpi: 72

Physical Width Inch: 4.1666665

Width: 300

Is Progressive: true

Is Transparent: false

Color Type: RGB

Uses Palette: false

The ImageInfo class can be used programtically to arrange files, or for other purposes as well

References

Sanselan Source

Sanselan Wiki


Leave a Reply

Your email address will not be published. Required fields are marked *