Interface IImage
interface IImage
Extends com.amazon.apmf.IStandard
IImage represents a decoded image in memory that can be drawn, transformed, manipulated or encoded.
It holds pixel data in a format optimized for rendering and
transformation. Images are immutable so operations like resize create
new image instances rather than modifying existing ones.
This interface provides APIs to query the image size, perform high-quality resizing
using filters and encode the image into various output formats.
Methods
getSize()
SizeI getSize()
Gets the SizeI of IImage.
Returns
SizeI
SizeI representing the width and height of the image.
resize()
Creates a new image by scaling this image to the specified dimensions. Image scaling is done using the specified sampling quality. The aspect ratio of the image is not preserved automatically and the image will be stretched to exactly match the target dimensions.IImage*resize(SizeItargetSize,ImageFilterQualityfilterQuality)
Parameters
targetSize
SizeI — Required
Desired width and height of the new image after resizing
filterQuality
ImageFilterQuality — Required
Sampling quality for the scaling operation
Returns
IImage*
A new image with the specified dimensions
Throws
InvalidArgumentError— if targetSize is invalid i.e. width or height is <= 0
encode()
Encodes this image’s pixels into the specified format. It supports common image formats with these characteristics:u8[]encode(EncodedImageFormatimageFormat)
- JPEG: Lossy compression, best for photos No alpha channel support File size depends on image complexity
- PNG: Lossless compression, best for graphics Supports alpha channel File size depends on image complexity
- WebP: Modern format with both lossy and lossless modes Typically smaller than JPEG/PNG Supports alpha channel
- JPEG is typically fastest
- PNG may be slow for complex images
- WebP encoding is slower but produces smaller files
Parameters
imageFormat
EncodedImageFormat — Required
The desired image format for encoding.
Returns
u8[]
Encoded image data in the specified format in the form of a byte array
Throws
InvalidArgumentError— if the specified format is not supported

