ImageInfo

class ImageInfo(val format: ImageFormat, val width: Int, val height: Int, val bitDepth: Int, val hasAlpha: Boolean, val frameCount: Int, val loopCount: Long, val orientation: Orientation, val isDecodable: Boolean, val unsupportedReason: String? = null, val pageCount: Int = 1, val colorProfile: ColorProfile? = null)(source)

What a file says about itself, read from its header alone: no pixel decode, no multi-megabyte allocation. This is what you want for laying out a grid before the images arrive, rejecting an upload that's 20000 px wide, or deciding whether a decoder should claim a file at all.

val info = ImageKodec.probe(bytes)
if (info.width.toLong() * info.height > budget) reject()
grid.reserve(info.displayWidth, info.displayHeight) // orientation applied

Cost is proportional to the header, not the image: a few hundred bytes for PNG/JPEG/BMP/TIFF/WebP. GIF walks frame descriptors while skipping compressed sub-blocks. APNG reports the frame count declared by acTL; only animation decoding validates that the complete frame sequence matches that declaration.

Constructors

Link copied to clipboard
constructor(format: ImageFormat, width: Int, height: Int, bitDepth: Int, hasAlpha: Boolean, frameCount: Int, loopCount: Long, orientation: Orientation, isDecodable: Boolean, unsupportedReason: String? = null, pageCount: Int = 1, colorProfile: ColorProfile? = null)

Properties

Link copied to clipboard

bits per channel as stored (8 for most things, 1..16 for PNG/TIFF)

Link copied to clipboard

The colour channels the image decodes to, known from the header before any decode: 1 for gray, 3 for colour (RGB or YCbCr), 4 for CMYK or YCCK, whose ink a decode converts, and 0 where the format cannot say from its header. A palette counts as the colours it holds. For a JPEG 2000 image it follows the colour boxes (colr, pclr, cmap, cdef, ITU-T T.800 I.5.3), so it agrees with what the decoder gives, and a renderer can fix an image's colour space when a page loads without decoding it (#119).

Link copied to clipboard

what the file declares about its color space (an embedded ICC profile, and PNG's sRGB, gamma, chromaticity and cICP chunks), or null when it declares nothing. A decode applies it only when its colorTarget asks; without one, decoded samples are the file's own.

Link copied to clipboard

height after orientation is applied.

Link copied to clipboard

width after orientation is applied: what the user will actually see.

Link copied to clipboard

the container, same value ImageKodec.detect returns

Link copied to clipboard

number of animation frames; 1 for stills, and 1 for every page of a TIFF, whose pages are separate images rather than frames

Link copied to clipboard

the file declares an alpha channel or transparency. This is what the container says, not a pixel scan: an RGBA PNG whose pixels are all opaque still reports true. Use KiteBitmap.hasTransparency for the truth.

Link copied to clipboard
val height: Int

stored pixel height, before orientation

Link copied to clipboard

True when frameCount> 1.

Link copied to clipboard

whether this build's ImageKodec.decode can actually produce pixels for this file. False means the format or a specific feature isn't implemented; unsupportedReason names it. It is also false for WebP data that ends before its first image chunk, because nothing yet says what the image holds.

Link copied to clipboard

total animation plays, normalized across formats: 0 = forever, 1 for stills. Long preserves the full unsigned APNG play field.

Link copied to clipboard

the EXIF orientation, Orientation.Normal when absent

Link copied to clipboard

number of pages: every image file directory in a TIFF's main chain, every top-level image of a HEIC or AVIF file (its images that are no thumbnail, auxiliary image, tile or other alternative of the primary, the primary first), and 1 for every other format. The other fields describe the page that was probed, the first unless ImageKodec.probePage asked for another.

Link copied to clipboard

The page of the left-eye image of a stereo pair, such as a spatial photo, or -1: a HEIF file's ster entity group names its two images, and each is a page (#168).

Link copied to clipboard

The page of the right-eye image of a stereo pair, or -1. See stereoLeftPage.

Link copied to clipboard
Link copied to clipboard

The size of the largest thumbnail the file carries, or 0 by 0 for none: the thmb items of a HEIC or AVIF file, or the thumbnail in the EXIF of a JPEG. ImageKodec.decodeThumbnail decodes one (#150).

Link copied to clipboard

human-readable reason when isDecodable is false

Link copied to clipboard
val width: Int

stored pixel width, before orientation

Functions

Link copied to clipboard
open override fun toString(): String