GifImage Class

Summary: The API for Graphical Interchange Format (GIF) image file provides
developers with versatile tools for processing compressed raster images and
animated GIFs. Offering features like XMP metadata handling, color palette
settings, background and transparent color control, opacity settings, resize,
crop, filter application, gamma corrections, contrast adjustment, grayscale
transformation, and conversion to other formats. This API empowers seamless
manipulation and enhancement of GIF images for a wide range of applications.

Module: aspose.imaging.fileformats.gif

Full Name: aspose.imaging.fileformats.gif.GifImage

Inheritance: IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImage, IMultipageImageExt, RasterCachedMultipageImage

Aspose.Imaging Version: 24.7.0

Constructors

NameDescription
GifImage(first_frame)Crafting GIF images becomes effortless with the GifImage
constructor. With just the firstFrame parameter, it enters in a world of dynamic
visual communication.
GifImage(first_frame, global_palette)Initiate a new GifImage object with specified parameters for the
first frame and global palette. Start managing GIF images swiftly, ensuring
accurate representation with customizable settings for optimal results.
GifImage(first_frame, global_palette, is_palette_sorted, palette_color_resolution, palette_background_color_index, aspect_ratio, has_trailer)Get started effortlessly with the GifImage constructor. With this
simple method, you can dive into creating animated GIFs with ease. Just supply the
firstFrame, globalPalette, paletteColorResolution, aspectRatio, and other
parameters, and you’re ready to bring your visuals to life.

Properties

NameTypeAccessDescription
active_frameGifFrameBlockr/wManage and manipulate frames with this property, enabling smooth navigation and
modification of the active frame within the GIF image.
auto_adjust_paletteboolr/wGets or sets a value indicating whether automatic adjust palette.
background_colorColorr/wManage the background color of the GIF image with this property. You can set or
retrieve the background color to ensure consistency and enhance visual appeal.
background_color_indexbyter/wControl the background color index of the GIF image using this property. Set or
retrieve the index to maintain consistency or achieve desired visual effects.
bits_per_pixelintrGets the image bits per pixel count.
blocksIGifBlock[]rGain access to the GIF blocks seamlessly with this property, facilitating easy
retrieval and manipulation of the image’s underlying data structures.
boundsRectanglerGets the object bounds.
buffer_size_hintintr/wGets or sets the buffer size hint which is defined max allowed size for all internal buffers.
containerImagerGets the Image container.
data_stream_containerStreamContainerrGets the object’s data stream.
disposedboolrGets a value indicating whether this instance is disposed.
file_formatFileFormatrRetrieve the file format effortlessly with this property. It’s your go-to source
for identifying the format of your files. Seamlessly integrated into your workflow,
it provides vital information without any hassle.
has_alphaboolrGets a value indicating whether this instance has alpha.
has_background_colorboolr/wThis property determines whether the GIF image contains a background color. If
true, it indicates that the image includes a background color.
has_trailerboolr/wManage the presence of a trailer in your GIF files with this property. Whether you
need to check if a trailer exists or set its presence, this property simplifies the
process. Keep your GIF files structured and compliant with this intuitive feature.
has_transparent_colorboolr/wDetermine whether the active frame of the GIF image includes a transparent color.
This property provides a convenient way to check for transparency within the image.
heightintrGets the image height.
horizontal_resolutiondoubler/wGets or sets the horizontal resolution, in pixels per inch, of this RasterImage.
image_opacityfloatrRetrieve the opacity of the active frame within the image, offering insight into
its transparency level. This property is particularly useful for understanding the
degree of transparency or opaqueness of the active frame in the image.
interrupt_monitorInterruptMonitorr/wGets or sets the interrupt monitor.
is_cachedboolrGets a value indicating whether image data is cached currently.
is_interlacedboolrDetermines if the image is interlaced, impacting its display during loading. This
property offers insight into the image’s rendering behavior, essential for
optimizing loading strategies and enhancing overall viewing experience.
is_palette_sortedboolr/wControl the sorting of the palette in your GIF images using this property. Whether
you need to check if the palette is sorted or set the sorting behavior, this
property provides a straightforward way to manage the palette organization in your
GIF files.
is_raw_data_availableboolrGets a value indicating whether raw data loading is supported.
loops_countintr/wRetrieve the loop count effortlessly with this property. If your GIF image includes
loop information, this property gives you quick access to the loop count, enabling
you to seamlessly manage looping behavior in your GIF files.
page_countintrRetrieve the total number of pages contained within the image with this
straightforward property. Ideal for quickly assessing the extent of the image content.
pagesImage[]rGain access to the pages within the image through this convenient property,
allowing seamless navigation and manipulation of individual pages as needed.
paletteIColorPaletter/wGets or sets the color palette. The color palette is not used when pixels are represented directly.
palette_color_resolution_bitsbyter/wManage the palette color resolution of your GIF images with this property. Adjust
the number of bits used to represent colors in the palette, providing fine control
over color depth and image quality.
pixel_aspect_ratiobyter/wManage the pixel aspect ratio of the GIF image with this property. Set or retrieve
the aspect ratio to ensure accurate rendering and maintain visual fidelity.
premultiply_componentsboolr/wGets or sets a value indicating whether the image components must be premultiplied.
raw_custom_color_converterIColorConverterr/wGets or sets the custom color converter
raw_data_formatPixelDataFormatrGets the raw data format.
raw_data_settingsRawDataSettingsrGets the current raw data settings. Note when using these settings the data loads without conversion.
raw_fallback_indexintr/wGets or sets the fallback index to use when palette index is out of bounds
raw_indexed_color_converterIIndexedColorConverterr/wGets or sets the indexed color converter
raw_line_sizeintrGets the raw line size in bytes.
sizeSizerGets the object size.
transparent_colorColorr/wRetrieve the transparent color of the active frame in the GIF image. This property
allows you to access the specific color that has been designated as transparent
within the currently active frame.
update_xmp_databoolr/wGets or sets a value indicating whether to update the XMP metadata.
use_paletteboolrGets a value indicating whether the image palette is used.
use_raw_databoolr/wGets or sets a value indicating whether to use raw data loading when the raw data loading is available.
vertical_resolutiondoubler/wGets or sets the vertical resolution, in pixels per inch, of this RasterImage.
widthintrGets the image width.
xmp_dataXmpPacketWrapperr/wManage XMP metadata with this property. Whether you’re retrieving existing metadata
or updating it with new information, this property streamlines the process. Keep
your metadata organized and accessible, ensuring that your files contain the
relevant information they need.

Methods

NameDescription
add_block(block)Adding a new GIF block allows you to include additional data within the image.
This method enables you to append custom blocks to the GIF image, which can
contain various types of information.
add_page(page)Incorporate a new page seamlessly into the existing image, enhancing its content
and expanding its scope. This method augment image collections with additional
content, fostering creativity and flexibility in image management and composition.
adjust_brightness(brightness)Adjusts the brightness of the image according to the specified
brightness parameter. This method modifies the brightness of
the entire image uniformly, enhancing or reducing the overall luminance to achieve
the desired effect.
adjust_contrast(contrast)Adjusts the contrast of the image, enhancing or reducing the difference in
brightness between pixels. This method modifies the image’s overall tonal range,
making darker areas darker and brighter areas brighter to improve visual clarity
and detail.
adjust_gamma(gamma)Enhance image quality by applying gamma correction. This method adjusts the color
gamma of the image to achieve optimal visual clarity. It modifies the gamma value
of each pixel, resulting in improved color rendition and overall image appearance.
adjust_gamma(gamma_red, gamma_green, gamma_blue)Gamma-correction of an image applies a nonlinear adjustment to the pixel values,
enhancing or reducing brightness based on the specified coefficients for the red,
green, and blue channels. This method helps to fine-tune the color balance and
luminance of the image, improving its overall appearance and visual quality.
binarize_bradley(brightness_difference)Binarization of an image using Bradley’s adaptive thresholding algorithm with
integral image thresholding is a method for converting a grayscale image into a
binary image. This algorithm calculates a local threshold for each pixel based on
the average intensity of the surrounding pixels within a specified window. By
adaptively adjusting the threshold based on local pixel intensities, Bradley’s
method is effective at handling variations in lighting and contrast across the image.
binarize_bradley(brightness_difference, window_size)Binarization of an image using Bradley’s adaptive thresholding algorithm using the integral image thresholding
binarize_fixed(threshold)Binarization of an image with a predefined threshold converts a grayscale or color
image into a binary image, where each pixel is classified as either black or white
based on whether its intensity value exceeds a specified threshold.
binarize_otsu()Binarization of an image with Otsu thresholding is a method used to automatically
determine the optimal threshold value for converting a grayscale image into a
binary image. The Otsu thresholding algorithm calculates the threshold that
minimizes the intra-class variance of the pixel intensities in the two resulting
classes (foreground and background). This technique is particularly useful when
the optimal threshold value is unknown and needs to be determined adaptively based
on the image’s histogram.
blend(origin, overlay, overlay_alpha)Blends this image instance with the overlay image.
blend(origin, overlay, overlay_area, overlay_alpha)Blends this image instance with the overlay image.
cache_data()Caches the data private.
can_load(file_path)Determines whether image can be loaded from the specified file path.
can_load(file_path, load_options)Determines whether image can be loaded from the specified file path and optionally using the specified open options.
can_load(stream)Determines whether image can be loaded from the specified stream.
can_load(stream, load_options)Determines whether image can be loaded from the specified stream and optionally using the specified loadOptions.
can_load_stream(stream)Determines whether image can be loaded from the specified stream.
can_load_stream_with_options(stream, load_options)Determines whether image can be loaded from the specified stream and optionally using the specified loadOptions.
can_load_with_options(file_path, load_options)Determines whether image can be loaded from the specified file path and optionally using the specified open options.
can_save(options)Determines whether image can be saved to the specified file format represented by the passed save options.
clear_blocks()Clearing all the GIF blocks removes any existing data stored within the image.
This operation effectively resets the image to an empty state, removing any
previously added blocks. Use this method when you need to start fresh with a clean
slate for creating or modifying a GIF image.
create(image_options, width, height)Creates a new image using the specified create options.
create(images)Creates a new image using the specified images as pages
create(images, dispose_images)Creates a new image the specified images as pages.
crop(left_shift, right_shift, top_shift, bottom_shift)Crop image with shifts.
crop(rectangle)Crop the image using a specified rectangle area. This operation removes the outer
portion of the image, leaving only the selected region defined by the rectangle.
dither(dithering_method, bits_count)Performs dithering on the current image.
dither(dithering_method, bits_count, custom_palette)Apply dithering to the current image. This process enhances image quality by
reducing color banding and improving color transitions, resulting in a smoother
appearance.
filter(rectangle, options)Apply a specific filter to the designated area of the image, enhancing its visual
quality or altering its appearance as desired. This method selectively processes
pixels within the defined rectangle, allowing for targeted adjustments to be made
while preserving the integrity of the surrounding image data.
get_argb_32_pixel(x, y)Gets an image 32-bit ARGB pixel.
get_default_argb_32_pixels(rectangle)Gets the default 32-bit ARGB pixels array.
get_default_options(args)Gets the default options.
get_default_pixels(rectangle, partial_pixel_loader)Gets the default pixels array using partial pixel loader.
get_default_raw_data(rectangle, partial_raw_data_loader, raw_data_settings)Gets the default raw data array using partial pixel loader.
get_default_raw_data(rectangle, raw_data_settings)Gets the default raw data array.
get_file_format(file_path)Gets the file format.
get_file_format(stream)Gets the file format.
get_file_format_of_stream(stream)Gets the file format.
get_fitting_rectangle(rectangle, pixels, width, height)Gets rectangle which fits the current image.
get_fitting_rectangle(rectangle, width, height)Gets rectangle which fits the current image.
get_modify_date(use_default)Gets the date and time the resource image was last modified.
get_original_options()Retrieve the original file settings-based options, crucial for maintaining fidelity
and consistency in image processing and manipulation. This method allows seamless
integration of file-specific parameters into subsequent operations, ensuring
accurate rendition and adherence to the image’s inherent characteristics.
This can be helpful to keep bit-depth and other parameters of the original image unchanged.
For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the
DataStreamSupporter.save(file_path) method, the output PNG image with 8-bit per pixel will be produced.
To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them
to the Image.save(file_path, options) method as the second parameter.
get_pixel(x, y)Gets an image pixel.
get_proportional_height(width, height, new_width)Gets a proportional height.
get_proportional_width(width, height, new_height)Gets a proportional width.
get_serialized_stream(image_options, clipping_rectangle, page_number)Converts to aps.
get_skew_angle()Gets the skew angle.
This method is applicable to scanned text documents, to determine the skew angle when scanning.
grayscale()The transformation of an image to its grayscale representation converts the color
image into a grayscale version by removing color information while preserving
luminance. This process simplifies the image to shades of gray, making it suitable
for various applications such as printing, document processing, and grayscale
analysis.
insert_block(index, block)Inserting a new GIF block allows you to add custom data at a specific position
within the image. This method enables you to place custom blocks at a desired
location in the GIF image, providing flexibility in organizing and structuring the
image data.
load(file_path)Loads a new image from the specified file.
load(file_path, load_options)Loads a new image from the specified file.
load(stream)Loads a new image from the specified stream.
load(stream, load_options)Loads a new image from the specified stream.
load_argb_32_pixels(rectangle)Loads 32-bit ARGB pixels.
load_argb_64_pixels(rectangle)Loads 64-bit ARGB pixels.
load_cmyk_32_pixels(rectangle)Loads pixels in CMYK format.
load_cmyk_pixels(rectangle)Loads pixels in CMYK format.
This method is deprecated. Please use more effective the RasterImage.load_cmyk_32_pixels(rectangle) method.
load_partial_argb_32_pixels(rectangle, partial_pixel_loader)Loads 32-bit ARGB pixels partially (by blocks).
load_partial_argb_64_pixels(rectangle, partial_pixel_loader)Loads 64-bit ARGB pixels partially by packs.
load_partial_pixels(desired_rectangle, pixel_loader)Loads pixels partially by packs.
load_pixels(rectangle)Loads pixels.
load_raw_data(rectangle, dest_image_bounds, raw_data_settings, raw_data_loader)Loads raw data.
load_raw_data(rectangle, raw_data_settings, raw_data_loader)Loads raw data.
load_stream(stream)Loads a new image from the specified stream.
load_stream_with_options(stream, load_options)Loads a new image from the specified stream.
load_with_options(file_path, load_options)Loads a new image from the specified file.
normalize_angle()Normalizes the angle.
This method is applicable to scanned text documents to get rid of the skewed scan.
This method uses RasterImage.get_skew_angle() and RasterImage.rotate(angle) methods.
normalize_angle(resize_proportionally, background_color)Normalizes the angle.
This method is applicable to scanned text documents to get rid of the skewed scan.
This method uses RasterImage.get_skew_angle() and RasterCachedMultipageImage.rotate(angle, resize_proportionally, background_color) methods.
order_blocks()Ordering the GIF blocks according to the GIF specification ensures proper GIF
layout and compliance with the standard. This process involves arranging the
blocks in the correct sequence as defined by the specification. Additionally, it
may involve removing certain GifGraphicsControlBlock instances that
are not necessary for the final layout. By adhering to the GIF specification, the
resulting image will be correctly structured and compatible with GIF viewing
applications.
read_argb_32_scan_line(scan_line_index)Reads the whole scan line by the specified scan line index.
read_scan_line(scan_line_index)Reads the whole scan line by the specified scan line index.
remove_block(block)Removing a GIF block removes specific data from the image, offering the ability to
clean up or modify the image structure. This method enables you to remove unwanted
or unnecessary blocks, optimizing the GIF image for efficient storage. Use this
functionality to eliminate outdated information from the image while preserving
its integrity and quality.
remove_metadata()Removes this image instance metadata by setting this IHasXmpData.xmp_data value to None.
replace_argb(old_color_argb, old_color_diff, new_color_argb)Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges.
replace_color(old_color, old_color_diff, new_color)Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges.
replace_color(old_color_argb, old_color_diff, new_color_argb)Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges.
replace_non_transparent_colors(new_color)Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges.
Note: if you use it on images without transparency, all colors will be replaced with a single one.
replace_non_transparent_colors(new_color_argb)Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges.
Note: if you use it on images without transparency, all colors will be replaced with a single one.
resize(new_width, new_height)Resizes the image. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.
resize(new_width, new_height, resize_type)Resizes the image.
resize(new_width, new_height, settings)Resizes the image.
resize_by_settings(new_width, new_height, settings)Resizes the image.
resize_by_type(new_width, new_height, resize_type)Resizes the image.
resize_full_frame(new_width, new_height, resize_type)Resizing of the image while taking into account the full frames for each page in a
GIF, thus preventing potential artifacts from appearing. This method is essential
to maintain the integrity and quality of the image, especially when dealing with
animated GIFs or sequences of frames.
resize_height_proportionally(new_height)Resizes the height proportionally. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.
resize_height_proportionally(new_height, resize_type)Resizes the width proportionally.
resize_height_proportionally(new_height, settings)Resizes the height proportionally.
resize_height_proportionally_settings(new_height, settings)Resizes the height proportionally.
resize_proportional(new_width, new_height, resize_type)Proportional resizing maintains the aspect ratio of the image while adjusting its
size, ensuring that the image does not appear stretched or distorted. This method
resizes the image proportionally, scaling both the width and height by the same factor.
The proportional resize will resize each frame according to the ratio of newWidth/width and newHeight/height.
resize_width_proportionally(new_width)Resizes the width proportionally. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.
resize_width_proportionally(new_width, resize_type)Resizes the width proportionally.
resize_width_proportionally(new_width, settings)Resizes the width proportionally.
resize_width_proportionally_settings(new_width, settings)Resizes the width proportionally.
rotate(angle)Rotate image around the center.
rotate(angle, resize_proportionally, background_color)This method rotates the image around its center point. By specifying the rotation
angle, you can rotate the image clockwise or counterclockwise to achieve the
desired orientation. This rotation helps adjust the image’s presentation or
alignment without distorting its content.
rotate_flip(rotate_flip_type)Perform rotation, flipping, or both on the active frame exclusively. This operation
applies transformations solely to the currently active frame of the image,
preserving the integrity of other frames in the sequence.
rotate_flip_all(rotate_flip)Rotates the flip all.
save()Saves the image data to the underlying stream.
save(file_path)Saves the image to the specified file location.
save(file_path, options)Saves the object’s data to the specified file location in the specified file format according to save options.
save(file_path, options, bounds_rectangle)Saves the object’s data to the specified file location in the specified file format according to save options.
save(file_path, over_write)Saves the object’s data to the specified file location.
save(stream)Saves the object’s data to the specified stream.
save(stream, options_base)Saves the image’s data to the specified stream in the specified file format according to save options.
save(stream, options_base, bounds_rectangle)Saves the image’s data to the specified stream in the specified file format according to save options.
save_argb_32_pixels(rectangle, pixels)Saves the 32-bit ARGB pixels.
save_cmyk_32_pixels(rectangle, pixels)Saves the pixels.
save_cmyk_pixels(rectangle, pixels)Saves the pixels.
This method is deprecated. Please use more effective the RasterImage.save_cmyk_32_pixels(rectangle, pixels) method.
save_pixels(rectangle, pixels)Saves the pixels internal main.
save_raw_data(data, data_offset, rectangle, raw_data_settings)Saves the raw data.
save_to_stream(stream)Saves the object’s data to the specified stream.
save_to_stream_with_options(stream, options_base)Saves the image’s data to the specified stream in the specified file format according to save options.
save_to_stream_with_options_rect(stream, options_base, bounds_rectangle)Saves the image’s data to the specified stream in the specified file format according to save options.
save_with_options(file_path, options)Saves the object’s data to the specified file location in the specified file format according to save options.
save_with_options_rect(file_path, options, bounds_rectangle)Saves the object’s data to the specified file location in the specified file format according to save options.
set_argb_32_pixel(x, y, argb_32_color)Sets an image 32-bit ARGB pixel for the specified position.
set_frame_time(time)Adjusts the duration of each frame in milliseconds, ensuring consistent timing
throughout the image sequence. This method uniformly sets the display time for
every frame, allowing for precise control over animation speed.
Changing this value will reset delay for all frames.
set_palette(palette, update_colors)Sets the image palette.
set_pixel(x, y, color)Sets an image pixel for the specified position.
set_resolution(dpi_x, dpi_y)Sets the resolution for this RasterImage.
write_argb_32_scan_line(scan_line_index, argb_32_pixels)Writes the whole scan line to the specified scan line index.
write_scan_line(scan_line_index, pixels)Writes the whole scan line to the specified scan line index.

Constructor: GifImage(first_frame)

 GifImage(first_frame) 

Crafting GIF images becomes effortless with the GifImage
constructor. With just the firstFrame parameter, it enters in a world of dynamic
visual communication.

Parameters:

ParameterTypeDescription
first_frameGifFrameBlockThe first frame to initialize gif image with.

See also:

Example # 1: This example shows how to create a GIF image and save it to a file.

Example # 2: The following example shows how to compose an animated GIF image from individ…

Constructor: GifImage(first_frame, global_palette)

 GifImage(first_frame, global_palette) 

Initiate a new GifImage object with specified parameters for the
first frame and global palette. Start managing GIF images swiftly, ensuring
accurate representation with customizable settings for optimal results.

Parameters:

ParameterTypeDescription
first_frameGifFrameBlockThe first frame to initialize gif image with.
global_paletteIColorPaletteThe global palette to use. Note if both firstFrame and globalPalette are null then default global palette is used.

See also:

Example # 1: This example shows how to create a GIF image with a custom palette and save i…

Constructor: GifImage(first_frame, global_palette, is_palette_sorted, palette_color_resolution, palette_background_color_index, aspect_ratio, has_trailer)

 GifImage(first_frame, global_palette, is_palette_sorted, palette_color_resolution, palette_background_color_index, aspect_ratio, has_trailer) 

Get started effortlessly with the GifImage constructor. With this
simple method, you can dive into creating animated GIFs with ease. Just supply the
firstFrame, globalPalette, paletteColorResolution, aspectRatio, and other
parameters, and you’re ready to bring your visuals to life.

Parameters:

ParameterTypeDescription
first_frameGifFrameBlockThe first frame to initialize gif image with.
global_paletteIColorPaletteThe global palette to use. Note if both firstFrame and globalPalette are null then default global palette is used.
is_palette_sortedboolif set to true the palette is sorted. Note the parameter is used when globalPalette is not null.
palette_color_resolutionbyteThe palette color resolution. Note the parameter is used when globalPalette is not null.
palette_background_color_indexbyteThe palette background color index.
aspect_ratiobyteThe aspect ratio.
has_trailerboolif set to true the gif image has trailer otherwise no trailer written at the end of the stream.

Property: active_frame

Manage and manipulate frames with this property, enabling smooth navigation and
modification of the active frame within the GIF image.

See also:

Example # 1: The following example shows how to remove all blocks from a GIF image.

Method: add_block(block)

 add_block(block) 

Adding a new GIF block allows you to include additional data within the image.
This method enables you to append custom blocks to the GIF image, which can
contain various types of information.

Parameters:

ParameterTypeDescription
blockIGifBlockThe GIF block to add.

See also:

Example # 1: The following example shows how to compose an animated GIF image from individ…

Method: add_page(page)

 add_page(page) 

Incorporate a new page seamlessly into the existing image, enhancing its content
and expanding its scope. This method augment image collections with additional
content, fostering creativity and flexibility in image management and composition.

Parameters:

ParameterTypeDescription
pageRasterImageThe page to add.

Method: adjust_brightness(brightness)

 adjust_brightness(brightness) 

Adjusts the brightness of the image according to the specified
brightness parameter. This method modifies the brightness of
the entire image uniformly, enhancing or reducing the overall luminance to achieve
the desired effect.

Parameters:

ParameterTypeDescription
brightnessintBrightness value.

Method: adjust_contrast(contrast)

 adjust_contrast(contrast) 

Adjusts the contrast of the image, enhancing or reducing the difference in
brightness between pixels. This method modifies the image’s overall tonal range,
making darker areas darker and brighter areas brighter to improve visual clarity
and detail.

Parameters:

ParameterTypeDescription
contrastfloatContrast value (in range [-100; 100])

Method: adjust_gamma(gamma)

 adjust_gamma(gamma) 

Enhance image quality by applying gamma correction. This method adjusts the color
gamma of the image to achieve optimal visual clarity. It modifies the gamma value
of each pixel, resulting in improved color rendition and overall image appearance.

Parameters:

ParameterTypeDescription
gammafloatGamma for red, green and blue channels coefficient

Method: adjust_gamma(gamma_red, gamma_green, gamma_blue)

 adjust_gamma(gamma_red, gamma_green, gamma_blue) 

Gamma-correction of an image applies a nonlinear adjustment to the pixel values,
enhancing or reducing brightness based on the specified coefficients for the red,
green, and blue channels. This method helps to fine-tune the color balance and
luminance of the image, improving its overall appearance and visual quality.

Parameters:

ParameterTypeDescription
gamma_redfloatGamma for red channel coefficient
gamma_greenfloatGamma for green channel coefficient
gamma_bluefloatGamma for blue channel coefficient

Method: binarize_bradley(brightness_difference)

 binarize_bradley(brightness_difference) 

Binarization of an image using Bradley’s adaptive thresholding algorithm with
integral image thresholding is a method for converting a grayscale image into a
binary image. This algorithm calculates a local threshold for each pixel based on
the average intensity of the surrounding pixels within a specified window. By
adaptively adjusting the threshold based on local pixel intensities, Bradley’s
method is effective at handling variations in lighting and contrast across the image.

Parameters:

ParameterTypeDescription
brightness_differencedoubleThe brightness difference between pixel and the average of an s x s window of pixels centered around this pixel.

Method: binarize_bradley(brightness_difference, window_size)

 binarize_bradley(brightness_difference, window_size) 

Binarization of an image using Bradley’s adaptive thresholding algorithm using the integral image thresholding

Parameters:

ParameterTypeDescription
brightness_differencedoubleThe brightness difference between pixel and the average of an s x s window of pixels
centered around this pixel.
window_sizeintThe size of s x s window of pixels centered around this pixel

Method: binarize_fixed(threshold)

 binarize_fixed(threshold) 

Binarization of an image with a predefined threshold converts a grayscale or color
image into a binary image, where each pixel is classified as either black or white
based on whether its intensity value exceeds a specified threshold.

Parameters:

ParameterTypeDescription
thresholdbyteThreshold value. If corresponding gray value of a pixel is greater than threshold, a value of 255 will be assigned to it, 0 otherwise.

Method: blend(origin, overlay, overlay_alpha)

 blend(origin, overlay, overlay_alpha) 

Blends this image instance with the overlay image.

Parameters:

ParameterTypeDescription
originPointThe background image blending origin.
overlayRasterImageThe overlay image.
overlay_alphabyteThe overlay alpha.

Method: blend(origin, overlay, overlay_area, overlay_alpha)

 blend(origin, overlay, overlay_area, overlay_alpha) 

Blends this image instance with the overlay image.

Parameters:

ParameterTypeDescription
originPointThe background image blending origin.
overlayRasterImageThe overlay image.
overlay_areaRectangleThe overlay area.
overlay_alphabyteThe overlay alpha.

Method: can_load(file_path) [static]

 can_load(file_path) 

Determines whether image can be loaded from the specified file path.

Parameters:

ParameterTypeDescription
file_pathstringThe file path.

Returns

TypeDescription
booltrue if image can be loaded from the specified file; otherwise, false.

Method: can_load(file_path, load_options) [static]

 can_load(file_path, load_options) 

Determines whether image can be loaded from the specified file path and optionally using the specified open options.

Parameters:

ParameterTypeDescription
file_pathstringThe file path.
load_optionsLoadOptionsThe load options.

Returns

TypeDescription
booltrue if image can be loaded from the specified file; otherwise, false.

Method: can_load(stream) [static]

 can_load(stream) 

Determines whether image can be loaded from the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load from.

Returns

TypeDescription
booltrue if image can be loaded from the specified stream; otherwise, false.

Method: can_load(stream, load_options) [static]

 can_load(stream, load_options) 

Determines whether image can be loaded from the specified stream and optionally using the specified loadOptions.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load from.
load_optionsLoadOptionsThe load options.

Returns

TypeDescription
booltrue if image can be loaded from the specified stream; otherwise, false.

Method: can_load_stream(stream) [static]

 can_load_stream(stream) 

Determines whether image can be loaded from the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load from.

Returns

TypeDescription
booltrue if image can be loaded from the specified stream; otherwise, false.

Method: can_load_stream_with_options(stream, load_options) [static]

 can_load_stream_with_options(stream, load_options) 

Determines whether image can be loaded from the specified stream and optionally using the specified loadOptions.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load from.
load_optionsLoadOptionsThe load options.

Returns

TypeDescription
booltrue if image can be loaded from the specified stream; otherwise, false.

Method: can_load_with_options(file_path, load_options) [static]

 can_load_with_options(file_path, load_options) 

Determines whether image can be loaded from the specified file path and optionally using the specified open options.

Parameters:

ParameterTypeDescription
file_pathstringThe file path.
load_optionsLoadOptionsThe load options.

Returns

TypeDescription
booltrue if image can be loaded from the specified file; otherwise, false.

Method: can_save(options)

 can_save(options) 

Determines whether image can be saved to the specified file format represented by the passed save options.

Parameters:

ParameterTypeDescription
optionsImageOptionsBaseThe save options to use.

Returns

TypeDescription
booltrue if image can be saved to the specified file format represented by the passed save options; otherwise, false.

Method: create(image_options, width, height) [static]

 create(image_options, width, height) 

Creates a new image using the specified create options.

Parameters:

ParameterTypeDescription
image_optionsImageOptionsBaseThe image options.
widthintThe width.
heightintThe height.

Returns

TypeDescription
ImageThe newly created image.

Method: create(images) [static]

 create(images) 

Creates a new image using the specified images as pages

Parameters:

ParameterTypeDescription
imagesImage[]The images.

Returns

TypeDescription
ImageThe Image as IMultipageImage

Method: create(images, dispose_images) [static]

 create(images, dispose_images) 

Creates a new image the specified images as pages.

Parameters:

ParameterTypeDescription
imagesImage[]The images.
dispose_imagesboolif set to true [dispose images].

Returns

TypeDescription
ImageThe Image as IMultipageImage

Method: crop(left_shift, right_shift, top_shift, bottom_shift)

 crop(left_shift, right_shift, top_shift, bottom_shift) 

Crop image with shifts.

Parameters:

ParameterTypeDescription
left_shiftintThe left shift.
right_shiftintThe right shift.
top_shiftintThe top shift.
bottom_shiftintThe bottom shift.

Method: crop(rectangle)

 crop(rectangle) 

Crop the image using a specified rectangle area. This operation removes the outer
portion of the image, leaving only the selected region defined by the rectangle.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle.

Method: dither(dithering_method, bits_count)

 dither(dithering_method, bits_count) 

Performs dithering on the current image.

Parameters:

ParameterTypeDescription
dithering_methodDitheringMethodThe dithering method.
bits_countintThe final bits count for dithering.

Method: dither(dithering_method, bits_count, custom_palette)

 dither(dithering_method, bits_count, custom_palette) 

Apply dithering to the current image. This process enhances image quality by
reducing color banding and improving color transitions, resulting in a smoother
appearance.

Parameters:

ParameterTypeDescription
dithering_methodDitheringMethodThe dithering method.
bits_countintThe final bits count for dithering.
custom_paletteIColorPaletteThe custom palette for dithering.

Method: filter(rectangle, options)

 filter(rectangle, options) 

Apply a specific filter to the designated area of the image, enhancing its visual
quality or altering its appearance as desired. This method selectively processes
pixels within the defined rectangle, allowing for targeted adjustments to be made
while preserving the integrity of the surrounding image data.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle.
optionsFilterOptionsBaseThe options.

Method: get_argb_32_pixel(x, y)

 get_argb_32_pixel(x, y) 

Gets an image 32-bit ARGB pixel.

Parameters:

ParameterTypeDescription
xintThe pixel x location.
yintThe pixel y location.

Returns

TypeDescription
intThe 32-bit ARGB pixel for the specified location.

Method: get_default_argb_32_pixels(rectangle)

 get_default_argb_32_pixels(rectangle) 

Gets the default 32-bit ARGB pixels array.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to get pixels for.

Returns

TypeDescription
intThe default pixels array.

Method: get_default_options(args)

 get_default_options(args) 

Gets the default options.

Parameters:

ParameterTypeDescription
argsobjectThe arguments.

Returns

TypeDescription
ImageOptionsBaseDefault options

Method: get_default_pixels(rectangle, partial_pixel_loader)

 get_default_pixels(rectangle, partial_pixel_loader) 

Gets the default pixels array using partial pixel loader.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to get pixels for.
partial_pixel_loaderIPartialArgb32PixelLoaderThe partial pixel loader.

Method: get_default_raw_data(rectangle, partial_raw_data_loader, raw_data_settings)

 get_default_raw_data(rectangle, partial_raw_data_loader, raw_data_settings) 

Gets the default raw data array using partial pixel loader.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to get pixels for.
partial_raw_data_loaderIPartialRawDataLoaderThe partial raw data loader.
raw_data_settingsRawDataSettingsThe raw data settings.

Method: get_default_raw_data(rectangle, raw_data_settings)

 get_default_raw_data(rectangle, raw_data_settings) 

Gets the default raw data array.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to get raw data for.
raw_data_settingsRawDataSettingsThe raw data settings.

Returns

TypeDescription
byteThe default raw data array.

Method: get_file_format(file_path) [static]

 get_file_format(file_path) 

Gets the file format.

Parameters:

ParameterTypeDescription
file_pathstringThe file path.

Returns

TypeDescription
FileFormatThe determined file format.

Method: get_file_format(stream) [static]

 get_file_format(stream) 

Gets the file format.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream.

Returns

TypeDescription
FileFormatThe determined file format.

Method: get_file_format_of_stream(stream) [static]

 get_file_format_of_stream(stream) 

Gets the file format.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream.

Returns

TypeDescription
FileFormatThe determined file format.

Method: get_fitting_rectangle(rectangle, pixels, width, height) [static]

 get_fitting_rectangle(rectangle, pixels, width, height) 

Gets rectangle which fits the current image.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to get fitting rectangle for.
pixelsintThe 32-bit ARGB pixels.
widthintThe object width.
heightintThe object height.

Returns

TypeDescription
RectangleThe fitting rectangle or exception if no fitting rectangle can be found.

Method: get_fitting_rectangle(rectangle, width, height) [static]

 get_fitting_rectangle(rectangle, width, height) 

Gets rectangle which fits the current image.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to get fitting rectangle for.
widthintThe object width.
heightintThe object height.

Returns

TypeDescription
RectangleThe fitting rectangle or exception if no fitting rectangle can be found.

Method: get_modify_date(use_default)

 get_modify_date(use_default) 

Gets the date and time the resource image was last modified.

Parameters:

ParameterTypeDescription
use_defaultboolif set to true uses the information from FileInfo as default value.

Returns

TypeDescription
datetimeThe date and time the resource image was last modified.

Method: get_original_options()

 get_original_options() 

Retrieve the original file settings-based options, crucial for maintaining fidelity
and consistency in image processing and manipulation. This method allows seamless
integration of file-specific parameters into subsequent operations, ensuring
accurate rendition and adherence to the image’s inherent characteristics.
This can be helpful to keep bit-depth and other parameters of the original image unchanged.
For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the
DataStreamSupporter.save(file_path) method, the output PNG image with 8-bit per pixel will be produced.
To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them
to the Image.save(file_path, options) method as the second parameter.

Returns

TypeDescription
ImageOptionsBaseThe options based on the original file settings.

Method: get_pixel(x, y)

 get_pixel(x, y) 

Gets an image pixel.

Parameters:

ParameterTypeDescription
xintThe pixel x location.
yintThe pixel y location.

Returns

TypeDescription
ColorThe pixel color for the specified location.

Method: get_proportional_height(width, height, new_width) [static]

 get_proportional_height(width, height, new_width) 

Gets a proportional height.

Parameters:

ParameterTypeDescription
widthintThe width.
heightintThe height.
new_widthintThe new width.

Returns

TypeDescription
intThe proportional height.

Method: get_proportional_width(width, height, new_height) [static]

 get_proportional_width(width, height, new_height) 

Gets a proportional width.

Parameters:

ParameterTypeDescription
widthintThe width.
heightintThe height.
new_heightintThe new height.

Returns

TypeDescription
intThe proportional width.

Method: get_serialized_stream(image_options, clipping_rectangle, page_number)

 get_serialized_stream(image_options, clipping_rectangle, page_number) 

Converts to aps.

Parameters:

ParameterTypeDescription
image_optionsImageOptionsBaseThe image options.
clipping_rectangleRectangleThe clipping rectangle.
page_numberint[]The page number.

Returns

TypeDescription
_io.BufferedRandomThe serialized stream

Method: get_skew_angle()

 get_skew_angle() 

Gets the skew angle.
This method is applicable to scanned text documents, to determine the skew angle when scanning.

Returns

TypeDescription
floatThe skew angle, in degrees.

Method: insert_block(index, block)

 insert_block(index, block) 

Inserting a new GIF block allows you to add custom data at a specific position
within the image. This method enables you to place custom blocks at a desired
location in the GIF image, providing flexibility in organizing and structuring the
image data.

Parameters:

ParameterTypeDescription
indexintThe zero-based element, at which block will be inserted.
blockIGifBlockThe GIF block to add.

Method: load(file_path) [static]

 load(file_path) 

Loads a new image from the specified file.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to load image from.

Returns

TypeDescription
ImageThe loaded image.

Method: load(file_path, load_options) [static]

 load(file_path, load_options) 

Loads a new image from the specified file.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to load image from.
load_optionsLoadOptionsThe load options.

Returns

TypeDescription
ImageThe loaded image.

Method: load(stream) [static]

 load(stream) 

Loads a new image from the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load image from.

Returns

TypeDescription
ImageThe loaded image.

Method: load(stream, load_options) [static]

 load(stream, load_options) 

Loads a new image from the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load image from.
load_optionsLoadOptionsThe load options.

Returns

TypeDescription
ImageThe loaded image.

Method: load_argb_32_pixels(rectangle)

 load_argb_32_pixels(rectangle) 

Loads 32-bit ARGB pixels.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to load pixels from.

Returns

TypeDescription
intThe loaded 32-bit ARGB pixels array.

Method: load_argb_64_pixels(rectangle)

 load_argb_64_pixels(rectangle) 

Loads 64-bit ARGB pixels.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to load pixels from.

Returns

TypeDescription
longThe loaded 64-bit ARGB pixels array.

Method: load_cmyk_32_pixels(rectangle)

 load_cmyk_32_pixels(rectangle) 

Loads pixels in CMYK format.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to load pixels from.

Returns

TypeDescription
intThe loaded CMYK pixels presentes as 32-bit inateger values.

Method: load_cmyk_pixels(rectangle)

 load_cmyk_pixels(rectangle) 

Loads pixels in CMYK format.
This method is deprecated. Please use more effective the RasterImage.load_cmyk_32_pixels(rectangle) method.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to load pixels from.

Returns

TypeDescription
CmykColor[]The loaded CMYK pixels array.

Method: load_partial_argb_32_pixels(rectangle, partial_pixel_loader)

 load_partial_argb_32_pixels(rectangle, partial_pixel_loader) 

Loads 32-bit ARGB pixels partially (by blocks).

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to load pixels from.
partial_pixel_loaderIPartialArgb32PixelLoaderThe partial pixel loader.

Method: load_partial_argb_64_pixels(rectangle, partial_pixel_loader)

 load_partial_argb_64_pixels(rectangle, partial_pixel_loader) 

Loads 64-bit ARGB pixels partially by packs.

Parameters:

ParameterTypeDescription
rectangleRectangleThe desired rectangle.
partial_pixel_loaderIPartialArgb64PixelLoaderThe 64-bit ARGB pixel loader.

Method: load_partial_pixels(desired_rectangle, pixel_loader)

 load_partial_pixels(desired_rectangle, pixel_loader) 

Loads pixels partially by packs.

Parameters:

ParameterTypeDescription
desired_rectangleRectangleThe desired rectangle.
pixel_loaderIPartialPixelLoaderThe pixel loader.

Method: load_pixels(rectangle)

 load_pixels(rectangle) 

Loads pixels.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to load pixels from.

Returns

TypeDescription
Color[]The loaded pixels array.

Method: load_raw_data(rectangle, dest_image_bounds, raw_data_settings, raw_data_loader)

 load_raw_data(rectangle, dest_image_bounds, raw_data_settings, raw_data_loader) 

Loads raw data.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to load raw data from.
dest_image_boundsRectangleThe dest image bounds.
raw_data_settingsRawDataSettingsThe raw data settings to use for loaded data. Note if data is not in the format specified then data conversion will be performed.
raw_data_loaderIPartialRawDataLoaderThe raw data loader.

Method: load_raw_data(rectangle, raw_data_settings, raw_data_loader)

 load_raw_data(rectangle, raw_data_settings, raw_data_loader) 

Loads raw data.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to load raw data from.
raw_data_settingsRawDataSettingsThe raw data settings to use for loaded data. Note if data is not in the format specified then data conversion will be performed.
raw_data_loaderIPartialRawDataLoaderThe raw data loader.

Method: load_stream(stream) [static]

 load_stream(stream) 

Loads a new image from the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load image from.

Returns

TypeDescription
ImageThe loaded image.

Method: load_stream_with_options(stream, load_options) [static]

 load_stream_with_options(stream, load_options) 

Loads a new image from the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load image from.
load_optionsLoadOptionsThe load options.

Returns

TypeDescription
ImageThe loaded image.

Method: load_with_options(file_path, load_options) [static]

 load_with_options(file_path, load_options) 

Loads a new image from the specified file.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to load image from.
load_optionsLoadOptionsThe load options.

Returns

TypeDescription
ImageThe loaded image.

Method: normalize_angle(resize_proportionally, background_color)

 normalize_angle(resize_proportionally, background_color) 

Normalizes the angle.
This method is applicable to scanned text documents to get rid of the skewed scan.
This method uses RasterImage.get_skew_angle() and RasterCachedMultipageImage.rotate(angle, resize_proportionally, background_color) methods.

Parameters:

ParameterTypeDescription
resize_proportionallyboolif set to true you will have your image size changed according to rotated rectangle (corner points) projections in other case that leaves dimensions untouched and only internal image contents are rotated.
background_colorColorColor of the background.

Method: read_argb_32_scan_line(scan_line_index)

 read_argb_32_scan_line(scan_line_index) 

Reads the whole scan line by the specified scan line index.

Parameters:

ParameterTypeDescription
scan_line_indexintZero based index of the scan line.

Returns

TypeDescription
intThe scan line 32-bit ARGB color values array.

Method: read_scan_line(scan_line_index)

 read_scan_line(scan_line_index) 

Reads the whole scan line by the specified scan line index.

Parameters:

ParameterTypeDescription
scan_line_indexintZero based index of the scan line.

Returns

TypeDescription
Color[]The scan line pixel color values array.

Method: remove_block(block)

 remove_block(block) 

Removing a GIF block removes specific data from the image, offering the ability to
clean up or modify the image structure. This method enables you to remove unwanted
or unnecessary blocks, optimizing the GIF image for efficient storage. Use this
functionality to eliminate outdated information from the image while preserving
its integrity and quality.

Parameters:

ParameterTypeDescription
blockIGifBlockThe block to remove.

Method: replace_argb(old_color_argb, old_color_diff, new_color_argb)

 replace_argb(old_color_argb, old_color_diff, new_color_argb) 

Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges.

Parameters:

ParameterTypeDescription
old_color_argbintOld color ARGB value to be replaced.
old_color_diffbyteAllowed difference in old color to be able to widen replaced color tone.
new_color_argbintNew color ARGB value to replace old color with.

Method: replace_color(old_color, old_color_diff, new_color)

 replace_color(old_color, old_color_diff, new_color) 

Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges.

Parameters:

ParameterTypeDescription
old_colorColor
old_color_diffbyteAllowed difference in old color to be able to widen replaced color tone.
new_colorColor

Method: replace_color(old_color_argb, old_color_diff, new_color_argb)

 replace_color(old_color_argb, old_color_diff, new_color_argb) 

Replaces one color to another with allowed difference and preserves original alpha value to save smooth edges.

Parameters:

ParameterTypeDescription
old_color_argbintOld color ARGB value to be replaced.
old_color_diffbyteAllowed difference in old color to be able to widen replaced color tone.
new_color_argbintNew color ARGB value to replace old color with.

Method: replace_non_transparent_colors(new_color)

 replace_non_transparent_colors(new_color) 

Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges.
Note: if you use it on images without transparency, all colors will be replaced with a single one.

Parameters:

ParameterTypeDescription
new_colorColor

Method: replace_non_transparent_colors(new_color_argb)

 replace_non_transparent_colors(new_color_argb) 

Replaces all non-transparent colors with new color and preserves original alpha value to save smooth edges.
Note: if you use it on images without transparency, all colors will be replaced with a single one.

Parameters:

ParameterTypeDescription
new_color_argbintNew color ARGB value to replace non transparent colors with.

Method: resize(new_width, new_height)

 resize(new_width, new_height) 

Resizes the image. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
new_heightintThe new height.

Method: resize(new_width, new_height, resize_type)

 resize(new_width, new_height, resize_type) 

Resizes the image.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
new_heightintThe new height.
resize_typeResizeTypeThe resize type.

Method: resize(new_width, new_height, settings)

 resize(new_width, new_height, settings) 

Resizes the image.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
new_heightintThe new height.
settingsImageResizeSettingsThe resize settings.

Method: resize_by_settings(new_width, new_height, settings)

 resize_by_settings(new_width, new_height, settings) 

Resizes the image.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
new_heightintThe new height.
settingsImageResizeSettingsThe resize settings.

Method: resize_by_type(new_width, new_height, resize_type)

 resize_by_type(new_width, new_height, resize_type) 

Resizes the image.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
new_heightintThe new height.
resize_typeResizeTypeThe resize type.

Method: resize_full_frame(new_width, new_height, resize_type)

 resize_full_frame(new_width, new_height, resize_type) 

Resizing of the image while taking into account the full frames for each page in a
GIF, thus preventing potential artifacts from appearing. This method is essential
to maintain the integrity and quality of the image, especially when dealing with
animated GIFs or sequences of frames.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
new_heightintThe new height.
resize_typeResizeTypeThe resize type.

Method: resize_height_proportionally(new_height)

 resize_height_proportionally(new_height) 

Resizes the height proportionally. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.

Parameters:

ParameterTypeDescription
new_heightintThe new height.

Method: resize_height_proportionally(new_height, resize_type)

 resize_height_proportionally(new_height, resize_type) 

Resizes the width proportionally.

Parameters:

ParameterTypeDescription
new_heightintThe new height.
resize_typeResizeTypeType of the resize.

Method: resize_height_proportionally(new_height, settings)

 resize_height_proportionally(new_height, settings) 

Resizes the height proportionally.

Parameters:

ParameterTypeDescription
new_heightintThe new height.
settingsImageResizeSettingsThe image resize settings.

Method: resize_height_proportionally_settings(new_height, settings)

 resize_height_proportionally_settings(new_height, settings) 

Resizes the height proportionally.

Parameters:

ParameterTypeDescription
new_heightintThe new height.
settingsImageResizeSettingsThe image resize settings.

Method: resize_proportional(new_width, new_height, resize_type)

 resize_proportional(new_width, new_height, resize_type) 

Proportional resizing maintains the aspect ratio of the image while adjusting its
size, ensuring that the image does not appear stretched or distorted. This method
resizes the image proportionally, scaling both the width and height by the same factor.
The proportional resize will resize each frame according to the ratio of newWidth/width and newHeight/height.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
new_heightintThe new height.
resize_typeResizeTypeThe resize type.

Method: resize_width_proportionally(new_width)

 resize_width_proportionally(new_width) 

Resizes the width proportionally. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.

Parameters:

ParameterTypeDescription
new_widthintThe new width.

Method: resize_width_proportionally(new_width, resize_type)

 resize_width_proportionally(new_width, resize_type) 

Resizes the width proportionally.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
resize_typeResizeTypeType of the resize.

Method: resize_width_proportionally(new_width, settings)

 resize_width_proportionally(new_width, settings) 

Resizes the width proportionally.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
settingsImageResizeSettingsThe image resize settings.

Method: resize_width_proportionally_settings(new_width, settings)

 resize_width_proportionally_settings(new_width, settings) 

Resizes the width proportionally.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
settingsImageResizeSettingsThe image resize settings.

Method: rotate(angle)

 rotate(angle) 

Rotate image around the center.

Parameters:

ParameterTypeDescription
anglefloatThe rotate angle in degrees. Positive values will rotate clockwise.

Method: rotate(angle, resize_proportionally, background_color)

 rotate(angle, resize_proportionally, background_color) 

This method rotates the image around its center point. By specifying the rotation
angle, you can rotate the image clockwise or counterclockwise to achieve the
desired orientation. This rotation helps adjust the image’s presentation or
alignment without distorting its content.

Parameters:

ParameterTypeDescription
anglefloatThe rotate angle in degrees. Positive values will rotate clockwise.
resize_proportionallyboolif set to true you will have your image size changed
according to rotated rectangle (corner points) projections in other
case that leaves dimensions untouched and only
internal image contents are rotated.
background_colorColorColor of the background.

Method: rotate_flip(rotate_flip_type)

 rotate_flip(rotate_flip_type) 

Perform rotation, flipping, or both on the active frame exclusively. This operation
applies transformations solely to the currently active frame of the image,
preserving the integrity of other frames in the sequence.

Parameters:

ParameterTypeDescription
rotate_flip_typeRotateFlipTypeThe rotate flip type.

Method: rotate_flip_all(rotate_flip)

 rotate_flip_all(rotate_flip) 

Rotates the flip all.

Parameters:

ParameterTypeDescription
rotate_flipRotateFlipTypeThe rotate flip.

Method: save(file_path)

 save(file_path) 

Saves the image to the specified file location.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to save the image to.

Method: save(file_path, options)

 save(file_path, options) 

Saves the object’s data to the specified file location in the specified file format according to save options.

Parameters:

ParameterTypeDescription
file_pathstringThe file path.
optionsImageOptionsBaseThe options.

Method: save(file_path, options, bounds_rectangle)

 save(file_path, options, bounds_rectangle) 

Saves the object’s data to the specified file location in the specified file format according to save options.

Parameters:

ParameterTypeDescription
file_pathstringThe file path.
optionsImageOptionsBaseThe options.
bounds_rectangleRectangleThe destination image bounds rectangle. Set the empty rectangle for use sourse bounds.

Method: save(file_path, over_write)

 save(file_path, over_write) 

Saves the object’s data to the specified file location.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to save the object’s data to.
over_writeboolif set to true over write the file contents, otherwise append will occur.

Method: save(stream)

 save(stream) 

Saves the object’s data to the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to save the object’s data to.

Method: save(stream, options_base)

 save(stream, options_base) 

Saves the image’s data to the specified stream in the specified file format according to save options.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to save the image’s data to.
options_baseImageOptionsBaseThe save options.

Method: save(stream, options_base, bounds_rectangle)

 save(stream, options_base, bounds_rectangle) 

Saves the image’s data to the specified stream in the specified file format according to save options.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to save the image’s data to.
options_baseImageOptionsBaseThe save options.
bounds_rectangleRectangleThe destination image bounds rectangle. Set the empty rectangle for use source bounds.

Method: save_argb_32_pixels(rectangle, pixels)

 save_argb_32_pixels(rectangle, pixels) 

Saves the 32-bit ARGB pixels.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to save pixels to.
pixelsintThe 32-bit ARGB pixels array.

Method: save_cmyk_32_pixels(rectangle, pixels)

 save_cmyk_32_pixels(rectangle, pixels) 

Saves the pixels.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to save pixels to.
pixelsintThe CMYK pixels presented as the 32-bit integer values.

Method: save_cmyk_pixels(rectangle, pixels)

 save_cmyk_pixels(rectangle, pixels) 

Saves the pixels.
This method is deprecated. Please use more effective the RasterImage.save_cmyk_32_pixels(rectangle, pixels) method.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle to save pixels to.
pixelsCmykColor[]The CMYK pixels array.

Method: save_pixels(rectangle, pixels)

 save_pixels(rectangle, pixels) 

Saves the pixels internal main.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle.
pixelsColor[]The pixels.

Method: save_raw_data(data, data_offset, rectangle, raw_data_settings)

 save_raw_data(data, data_offset, rectangle, raw_data_settings) 

Saves the raw data.

Parameters:

ParameterTypeDescription
databyteThe raw data.
data_offsetintThe starting raw data offset.
rectangleRectangleThe raw data rectangle.
raw_data_settingsRawDataSettingsThe raw data settings the data is in.

Method: save_to_stream(stream)

 save_to_stream(stream) 

Saves the object’s data to the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to save the object’s data to.

Method: save_to_stream_with_options(stream, options_base)

 save_to_stream_with_options(stream, options_base) 

Saves the image’s data to the specified stream in the specified file format according to save options.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to save the image’s data to.
options_baseImageOptionsBaseThe save options.

Method: save_to_stream_with_options_rect(stream, options_base, bounds_rectangle)

 save_to_stream_with_options_rect(stream, options_base, bounds_rectangle) 

Saves the image’s data to the specified stream in the specified file format according to save options.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to save the image’s data to.
options_baseImageOptionsBaseThe save options.
bounds_rectangleRectangleThe destination image bounds rectangle. Set the empty rectangle for use source bounds.

Method: save_with_options(file_path, options)

 save_with_options(file_path, options) 

Saves the object’s data to the specified file location in the specified file format according to save options.

Parameters:

ParameterTypeDescription
file_pathstringThe file path.
optionsImageOptionsBaseThe options.

Method: save_with_options_rect(file_path, options, bounds_rectangle)

 save_with_options_rect(file_path, options, bounds_rectangle) 

Saves the object’s data to the specified file location in the specified file format according to save options.

Parameters:

ParameterTypeDescription
file_pathstringThe file path.
optionsImageOptionsBaseThe options.
bounds_rectangleRectangleThe destination image bounds rectangle. Set the empty rectangle for use sourse bounds.

Method: set_argb_32_pixel(x, y, argb_32_color)

 set_argb_32_pixel(x, y, argb_32_color) 

Sets an image 32-bit ARGB pixel for the specified position.

Parameters:

ParameterTypeDescription
xintThe pixel x location.
yintThe pixel y location.
argb_32_colorintThe 32-bit ARGB pixel for the specified position.

Method: set_frame_time(time)

 set_frame_time(time) 

Adjusts the duration of each frame in milliseconds, ensuring consistent timing
throughout the image sequence. This method uniformly sets the display time for
every frame, allowing for precise control over animation speed.
Changing this value will reset delay for all frames.

Parameters:

ParameterTypeDescription
timeushortThe time of frame duration in milliseconds.

Method: set_palette(palette, update_colors)

 set_palette(palette, update_colors) 

Sets the image palette.

Parameters:

ParameterTypeDescription
paletteIColorPaletteThe palette to set.
update_colorsboolif set to true colors will be updated according to the new palette; otherwise color indexes remain unchanged. Note that unchanged indexes may crash the image on loading if some indexes have no corresponding palette entries.

Method: set_pixel(x, y, color)

 set_pixel(x, y, color) 

Sets an image pixel for the specified position.

Parameters:

ParameterTypeDescription
xintThe pixel x location.
yintThe pixel y location.
colorColorThe pixel color for the specified position.

Method: set_resolution(dpi_x, dpi_y)

 set_resolution(dpi_x, dpi_y) 

Sets the resolution for this RasterImage.

Parameters:

ParameterTypeDescription
dpi_xdoubleThe horizontal resolution, in dots per inch, of the RasterImage.
dpi_ydoubleThe vertical resolution, in dots per inch, of the RasterImage.

Method: write_argb_32_scan_line(scan_line_index, argb_32_pixels)

 write_argb_32_scan_line(scan_line_index, argb_32_pixels) 

Writes the whole scan line to the specified scan line index.

Parameters:

ParameterTypeDescription
scan_line_indexintZero based index of the scan line.
argb_32_pixelsintThe 32-bit ARGB colors array to write.

Method: write_scan_line(scan_line_index, pixels)

 write_scan_line(scan_line_index, pixels) 

Writes the whole scan line to the specified scan line index.

Parameters:

ParameterTypeDescription
scan_line_indexintZero based index of the scan line.
pixelsColor[]The pixel colors array to write.

Examples

This example shows how to create a GIF image and save it to a file.

from aspose.imaging.fileformats.gif.blocks import GifFrameBlock
from aspose.imaging.fileformats.gif import GifImage 
from aspose.imaging.brushes import SolidBrush
from aspose.imaging import Graphics, Color


# Create a GIF Frame block of 100x100 px.
with GifFrameBlock(100, 100) as firstBlock:
	# Fill the entire block in red.
	gr = Graphics(firstBlock)
	brush = SolidBrush(Color.red)
	gr.fill_rectangle(brush, firstBlock.bounds)

	with GifImage(firstBlock) as gifImage:
		gifImage.save("output.gif")

This example shows how to create a GIF image with a custom palette and save it to a file.

from aspose.imaging.fileformats.gif.blocks import GifFrameBlock
from aspose.imaging.fileformats.gif import GifImage 
from aspose.imaging.brushes import SolidBrush
from aspose.imaging import Graphics, Color, ColorPaletteHelper


# Create a GIF Frame block of 100x100 px.
with GifFrameBlock(100, 100) as firstBlock:
	# Fill the entire block in red.
	gr = Graphics(firstBlock)
	brush = SolidBrush(Color.red)
	gr.fill_rectangle(brush, firstBlock.bounds)

	# Use 4-bit palette to reduce the image size. The quality can get worse.
	palette = ColorPaletteHelper.create_4_bit()

	with GifImage(firstBlock, palette) as gifImage:
		gifImage.save("output.gif")

The following example shows how to compose an animated GIF image from individual GIF blocks.

from aspose.imaging.fileformats.gif.blocks import GifFrameBlock
from aspose.imaging.fileformats.gif import GifImage 
from aspose.imaging.brushes import SolidBrush
from aspose.imaging import Graphics, Color

# Create a GIF image 100 x 100 px.
# The first block is fully black by default.
with GifFrameBlock(100, 100) as firstBlock:
	with GifImage(firstBlock) as gifImage:
		# The first circle is red
		brush1 = SolidBrush(Color.red)

		# The second circle is black
		brush2 = SolidBrush(Color.black)

		# Gradually increase the angle of the red arc shape.
		for angle in range(10, 361, 10):
			block = GifFrameBlock(100, 100)
			gr = Graphics(block)
			gr.fill_pie(brush1, block.bounds, 0, angle)
			gifImage.add_block(block)
		
		# Gradually increase the angle of the black arc and wipe out the red arc.
		for angle in range(10, 361, 10):
			block = GifFrameBlock(100, 100)
			gr = Graphics(block)
			gr.fill_pie(brush2, block.bounds, 0, angle)
			gr.fill_pie(brush1, block.bounds, angle, 360 - angle)
			gifImage.add_block(block)

		gifImage.save("animated_radar.gif")

The following example shows how to remove all blocks from a GIF image.

from aspose.imaging.fileformats.gif.blocks import GifFrameBlock
from aspose.imaging.fileformats.gif import GifImage 

# Create a GIF image 100 x 100 px.
# The first block is fully black by default.
with GifFrameBlock(100, 100) as firstBlock:
	with GifImage(firstBlock) as gifImage:
		if gifImage.active_frame is not None:
			print(f"Active frame size: {gifImage.active_frame.size}")
		else:
			print("Active frame is not set")

		print("Clear all the blocks")
		gifImage.clear_blocks()

		if gifImage.active_frame is not None:
			print(f"Active frame size: {gifImage.active_frame.size}")
		else:
			print("Active frame is not set")

# The output looks like this:
# Active frame size: { Width = 100, Height = 100}
# Clear all the blocks
# Active frame is not set