PngImage

Inheritance: java.lang.Object, com.groupdocs.editor.htmlcss.resources.images.raster.RasterImageResourceBase

public final class PngImage extends RasterImageResourceBase

Represents one image in PNG (Portable Network Graphics) format with its metadata and additional methods

Constructors

Constructor Description
PngImage(String name, String contentInBase64) Creates new PngImage instance from content, represented as base64-encoded string, and with specified name
PngImage(String name, InputStream binaryContent) Creates new PngImage instance from content, represented as byte stream, and with specified name

Methods

Method Description
isValid(InputStream binaryContent) Checks whether specified stream is a valid PNG image
isValid(String contentInBase64) Checks whether specified base64-encoded string is a valid PNG image
getType() Returns ImageType.Png
reduceToNewHeight(int targetHeightInPixels) Creates and returns a new reduced PNG image, but with specified new reduced height and proportionally reduced width.

PngImage(String name, String contentInBase64)

public PngImage(String name, String contentInBase64)

Creates new PngImage instance from content, represented as base64-encoded string, and with specified name

Parameters:

Parameter Type Description
name java.lang.String Name of the PNG image. Cannot be null, empty or whitespaces.
contentInBase64 java.lang.String Content as base64-encoded string. Cannot be null, empty or whitespaces. If it is not a PNG content, exception will be thrown.

PngImage(String name, InputStream binaryContent)

public PngImage(String name, InputStream binaryContent)

Creates new PngImage instance from content, represented as byte stream, and with specified name

Parameters:

Parameter Type Description
name java.lang.String Name of the PNG image. Cannot be null, empty or whitespaces.
binaryContent java.io.InputStream Content as byte stream. Reading begins from original position. Cannot be null. Should be readable and seekable. If this instance will be disposed, this stream will be disposed too.

isValid(InputStream binaryContent)

public static boolean isValid(InputStream binaryContent)

Checks whether specified stream is a valid PNG image

Parameters:

Parameter Type Description
binaryContent java.io.InputStream Byte stream, that presumably contains a PNG image

Returns: boolean - True if specified stream contains valid PNG image, false otherwise

isValid(String contentInBase64)

public static boolean isValid(String contentInBase64)

Checks whether specified base64-encoded string is a valid PNG image

Parameters:

Parameter Type Description
contentInBase64 java.lang.String Content of the presumably PNG image in a form of base64-encoded string

Returns: boolean - True if specified string contains valid PNG image, false otherwise

getType()

public ImageType getType()

Returns ImageType.Png

Returns: ImageType -

reduceToNewHeight(int targetHeightInPixels)

public final PngImage reduceToNewHeight(int targetHeightInPixels)

Creates and returns a new reduced PNG image, but with specified new reduced height and proportionally reduced width.

Parameters:

Parameter Type Description
targetHeightInPixels int Height of the desired PNG image in pixels. Should be strictly lesser than original height.

Returns: PngImage - New PngImage instance with specified height