Package org.apache.commons.imaging

## Class ImageInfo

- java.lang.Object
- - org.apache.commons.imaging.ImageInfo

- Direct Known Subclasses:
    `PngImageInfo`

      public class ImageInfo
      extends Object

  ImageInfo represents a collection of basic properties of an image, such as width, height, format, bit depth, etc.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `static class` | `ImageInfo.ColorType` |
    `static class` | `ImageInfo.CompressionAlgorithm` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `ImageInfo​(String formatDetails, int bitsPerPixel, List<String> comments, ImageFormat format, String formatName, int height, String mimeType, int numberOfImages, int physicalHeightDpi, float physicalHeightInch, int physicalWidthDpi, float physicalWidthInch, int width, boolean progressive, boolean transparent, boolean usesPalette, ImageInfo.ColorType colorType, ImageInfo.CompressionAlgorithm compressionAlgorithm)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `dump()` |
    `int` | `getBitsPerPixel()` | Returns the bits per pixel of the image data.
    `ImageInfo.ColorType` | `getColorType()` | Returns the `ImageInfo.ColorType` of the image.
    `List<String>` | `getComments()` | Returns a list of comments from the image file.
    `ImageInfo.CompressionAlgorithm` | `getCompressionAlgorithm()` | Returns a description of the compression algorithm, if any.
    `ImageFormat` | `getFormat()` | Returns the image file format, ie.
    `String` | `getFormatDetails()` | Returns a description of the file format, ie.
    `String` | `getFormatName()` | Returns a string with the name of the image file format.
    `int` | `getHeight()` | Returns the height of the image in pixels.
    `String` | `getMimeType()` | Returns the MIME type of the image.
    `int` | `getNumberOfImages()` | Returns the number of images in the file.
    `int` | `getPhysicalHeightDpi()` | Returns horizontal dpi of the image, if available.
    `float` | `getPhysicalHeightInch()` | Returns physical height of the image in inches, if available.
    `int` | `getPhysicalWidthDpi()` | Returns vertical dpi of the image, if available.
    `float` | `getPhysicalWidthInch()` | Returns physical width of the image in inches, if available.
    `int` | `getWidth()` | Returns the width of the image in pixels.
    `boolean` | `isProgressive()` | Returns true if the image is progressive or interlaced.
    `boolean` | `isTransparent()` | Returns true if the image has transparency.
    `String` | `toString()` |
    `void` | `toString​(PrintWriter pw, String prefix)` |
    `boolean` | `usesPalette()` | Returns true if the image uses a palette.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### ImageInfo

          public ImageInfo​(String formatDetails,
                           int bitsPerPixel,
                           List<String> comments,
                           ImageFormat format,
                           String formatName,
                           int height,
                           String mimeType,
                           int numberOfImages,
                           int physicalHeightDpi,
                           float physicalHeightInch,
                           int physicalWidthDpi,
                           float physicalWidthInch,
                           int width,
                           boolean progressive,
                           boolean transparent,
                           boolean usesPalette,
                           ImageInfo.ColorType colorType,
                           ImageInfo.CompressionAlgorithm compressionAlgorithm)

  - ### Method Detail

    - #### getBitsPerPixel

          public int getBitsPerPixel()

      Returns the bits per pixel of the image data.
      Returns:
        bits per pixel of the image data.

    - #### getComments

          public List<String> getComments()

      Returns a list of comments from the image file.

      This is mostly obsolete.

      Returns:
        A list of comments.

    - #### getFormat

          public ImageFormat getFormat()

      Returns the image file format, ie. ImageFormat.IMAGE_FORMAT_PNG.

      Returns ImageFormat.IMAGE_FORMAT_UNKNOWN if format is unknown.

      Returns:
        a constant defined in ImageFormat.
      See Also:
        `ImageFormats`

    - #### getFormatName

          public String getFormatName()

      Returns a string with the name of the image file format.
      Returns:
        the name of the image file format.
      See Also:
        `getFormat()`

    - #### getHeight

          public int getHeight()

      Returns the height of the image in pixels.
      Returns:
        image height in pixels.
      See Also:
        `getWidth()`

    - #### getMimeType

          public String getMimeType()

      Returns the MIME type of the image.
      Returns:
        image MIME type.
      See Also:
        `getFormat()`

    - #### getNumberOfImages

          public int getNumberOfImages()

      Returns the number of images in the file.

      Applies mostly to GIF and TIFF; reading PSD/Photoshop layers is not supported, and Jpeg/JFIF EXIF thumbnails are not included in this count.

      Returns:
        number of images in the file.

    - #### getPhysicalHeightDpi

          public int getPhysicalHeightDpi()

      Returns horizontal dpi of the image, if available.

      Applies to TIFF (optional), BMP (always), GIF (constant: 72), Jpeg (optional), PNG (optional), PNM (constant: 72), PSD/Photoshop (constant: 72).

      Returns:
        returns -1 if not present.

    - #### getPhysicalHeightInch

          public float getPhysicalHeightInch()

      Returns physical height of the image in inches, if available.

      Applies to TIFF (optional), BMP (always), GIF (constant: 72), Jpeg (optional), PNG (optional), PNM (constant: 72), PSD/Photoshop (constant: 72).

      Returns:
        returns -1 if not present.

    - #### getPhysicalWidthDpi

          public int getPhysicalWidthDpi()

      Returns vertical dpi of the image, if available.

      Applies to TIFF (optional), BMP (always), GIF (constant: 72), Jpeg (optional), PNG (optional), PNM (constant: 72), PSD/Photoshop (constant: 72).

      Returns:
        returns -1 if not present.

    - #### getPhysicalWidthInch

          public float getPhysicalWidthInch()

      Returns physical width of the image in inches, if available.

      Applies to TIFF (optional), BMP (always), GIF (constant: 72), Jpeg (optional), PNG (optional), PNM (constant: 72), PSD/Photoshop (constant: 72).

      Returns:
        returns -1 if not present.

    - #### getWidth

          public int getWidth()

      Returns the width of the image in pixels.
      Returns:
        image width in pixels.
      See Also:
        `getHeight()`

    - #### isProgressive

          public boolean isProgressive()

      Returns true if the image is progressive or interlaced.
      Returns:
        `true` if the image is progressive or interlaced, `false` otherwise.

    - #### getColorType

          public ImageInfo.ColorType getColorType()

      Returns the `ImageInfo.ColorType` of the image.
      Returns:
        image color type.

    - #### dump

          public void dump()

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

    - #### toString

          public void toString​(PrintWriter pw,
                               String prefix)

    - #### getFormatDetails

          public String getFormatDetails()

      Returns a description of the file format, ie. format version.
      Returns:
        file format description.

    - #### isTransparent

          public boolean isTransparent()

      Returns true if the image has transparency.
      Returns:
        `true` if the image has transparency, `false` otherwise.

    - #### usesPalette

          public boolean usesPalette()

      Returns true if the image uses a palette.
      Returns:
        `true` if the image uses a palette, `false` otherwise.

    - #### getCompressionAlgorithm

          public ImageInfo.CompressionAlgorithm getCompressionAlgorithm()

      Returns a description of the compression algorithm, if any.
      Returns:
        compression algorithm description.