ApngOptions Class

Summary: The API for Animated PNG (Animated Portable Network Graphics) image file format
creation is a dynamic tool for developers seeking to generate captivating
animated images. With customizable options such as frame duration and the
number of times to loop, this API allows for fine-tuning animated content
according to specific needs. Whether creating engaging web graphics or
interactive visuals, you can leverage this API to seamlessly incorporate
APNG images with precise control over animation parameters.

Module: aspose.imaging.imageoptions

Full Name: aspose.imaging.imageoptions.ApngOptions

Inheritance: IHasXmpData, IHasMetadata, PngOptions

Constructors

NameDescription
ApngOptions()Initializes a new instance of the ApngOptions class.

Properties

NameTypeAccessDescription
DEFAULT_COMPRESSION_LEVEL [static]intrThe default compression level.
bit_depthbyter/wGets or sets the bit depth values in range of 1, 2, 4, 8, 16.


Mind the next limits:


PngColorType.GRAYSCALE, PngColorType.INDEXED_COLOR support bit depth of 1, 2, 4, 8.


PngColorType.GRAYSCALE_WITH_ALPHA supports bit depth of 8.


PngColorType.TRUECOLOR, PngColorType.TRUECOLOR_WITH_ALPHA support bit depth of 8, 16.

buffer_size_hintintr/wGets or sets the buffer size hint which is defined max allowed size for all internal buffers.
color_typePngColorTyper/wGets or sets the type of the color.
compression_levelintr/wGets or sets the PngImage compression level in the range of 0-9. The higher the value - the more efficient the compression.
default_frame_timeuintr/wGets or sets the default frame duration.
disposedboolrGets a value indicating whether this instance is disposed.
filter_typePngFilterTyper/wGets or sets the filter type used during png file save process.
full_frameboolr/wGets or sets a value indicating whether [full frame].
keep_metadataboolr/wGets a value whether to keep original image metadata on export.
multi_page_optionsMultiPageOptionsr/wThe multipage options
num_playsintr/wGets or sets the number of times to loop animation.
0 indicates infinite looping.
paletteIColorPaletter/wGets or sets the color palette.
progressiveboolr/wGets or sets a value indicating whether a PngImage is progressive.
resolution_settingsResolutionSettingr/wGets or sets the resolution settings.
sourceSourcer/wGets or sets the source to create image in.
vector_rasterization_optionsVectorRasterizationOptionsr/wGets or sets the vector rasterization options.
xmp_dataXmpPacketWrapperr/wGets or sets Xmp data.

Methods

NameDescription
clone()Creates a memberwise clone of this instance.

Constructor: ApngOptions()

 ApngOptions() 

Initializes a new instance of the ApngOptions class.

Property: default_frame_time

Gets or sets the default frame duration.

See also:

Example # 1: The following example shows how to export apng APNG file format from other no…

Property: num_plays

Gets or sets the number of times to loop animation.
0 indicates infinite looping.

See also:

Example # 1: The following example shows how to export to APNG file format.

Method: clone()

 clone() 

Creates a memberwise clone of this instance.

Returns

TypeDescription
ImageOptionsBaseA memberwise clone of this instance.

Examples

The following example shows how to export to APNG file format.


import aspose.pycore as aspycore
from aspose.imaging import *
from aspose.imaging.imageoptions import *

with Image.load("Animation1.webp") as image:
	# Export to APNG animation with unlimited animation cycles as default
	image.save("Animation1.webp.png", ApngOptions())
	# Setting up animation cycles
	obj_init = ApngOptions()
	# 5 cycles
	obj_init.num_plays = 5
	image.save("Animation2.webp.png", obj_init)

The following example shows how to export apng APNG file format from other non-animated multi-page format.


from aspose.imaging import Image
from aspose.imaging.imageoptions import ApngOptions

with Image.load("img4.tif") as image:
	# Setting up the default frame duration
	obj_init = ApngOptions()
	# 500 ms
	obj_init.default_frame_time = 500
	image.save("img4.tif.500ms.png", obj_init)
	obj_init2 = ApngOptions()
	# 250 ms
	obj_init2.default_frame_time = 250
	image.save("img4.tif.250ms.png", obj_init2)