DjvuImage Class
Summary: DjVu document class supports graphics file format and facilitates seamless
management of scanned documents and books, integrating text, drawings, images,
and photos into a single format. Supporting multi-page operations, you can
efficiently access unique document identifiers, count pages, set active pages,
and retrieve specific document pages. With features for resizing, rotating,
dithering, cropping, grayscale transformation, gamma corrections, adjustments,
and filters application, this class empowers precise manipulation and enhancement
of DjVu images to meet diverse application needs with ease and precision.
Module: aspose.imaging.fileformats.djvu
Full Name: aspose.imaging.fileformats.djvu.DjvuImage
Inheritance: IObjectWithBounds, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IHasXmpData, IHasMetadata, IMultipageImage, RasterCachedMultipageImage
Constructors
Name | Description |
---|---|
DjvuImage(stream) | Start working with DjVu images by initializing a new instance of the DjvuImage class using a Stream parameter. Perfect for developers who want seamless integration of DjVu image processing into their projects. |
DjvuImage(stream, load_options) | Start working with DjVu images seamlessly with this constructor, which initializes a new DjvuImage class instance using a Stream and LoadOptions parameters. Perfect for developers who want precise control over DjVu image loading options while maintaining simplicity and efficiency. |
Properties
Name | Type | Access | Description |
---|---|---|---|
active_page | DjvuPage | r/w | Navigate through your DjVu document by accessing or setting the currently active page using this property. Seamlessly switch between pages to focus on specific content and enhance your document viewing experience. |
auto_adjust_palette | bool | r/w | Gets or sets a value indicating whether automatic adjust palette. |
background_color | Color | r/w | Gets or sets a value for the background color. |
bits_per_pixel | int | r | Gets the image bits per pixel count. |
bounds | Rectangle | r | Gets the object bounds. |
buffer_size_hint | int | r/w | Gets or sets the buffer size hint which is defined max allowed size for all internal buffers. |
container | Image | r | Gets the Image container. |
data_stream_container | StreamContainer | r | Gets the object’s data stream. |
disposed | bool | r | Gets a value indicating whether this instance is disposed. |
djvu_pages | DjvuPage[] | r | Quickly retrieve all the pages contained within your DjVu document using this property. Simplify your document processing workflow by easily accessing and managing individual pages within your DjVu files. Improve efficiency and streamline your tasks with convenient page retrieval. |
file_format | FileFormat | r | Obtain the file format information associated with your DjVu image file. Quickly determine the format of your file for seamless integration into your workflow. |
first_page | DjvuPage | r | Access the first page of your DjVu document with this property. Quickly retrieve the initial page to begin viewing or processing your document efficiently. |
has_alpha | bool | r | Quickly determine whether your DjVu image file contains an alpha channel. Simplify your workflow by checking for the presence of transparency information in your images. |
has_background_color | bool | r/w | Gets or sets a value indicating whether image has background color. |
has_transparent_color | bool | r/w | Gets a value indicating whether image has transparent color. |
height | int | r | Gets the image height. |
horizontal_resolution | double | r/w | Gets or sets the horizontal resolution, in pixels per inch, of this RasterImage. |
identifier | int | r | Gets the unique identifier for the document |
image_opacity | float | r | Gets opacity of this image. |
interrupt_monitor | InterruptMonitor | r/w | Gets or sets the interrupt monitor. |
is_cached | bool | r | Gets a value indicating whether image data is cached currently. |
is_raw_data_available | bool | r | Gets a value indicating whether raw data loading is supported. |
last_page | DjvuPage | r | Retrieve the last page of your DjVu document using this property. Quickly access the final page for viewing or processing purposes with ease. |
next_page | DjvuPage | r | Navigate through your DjVu document by accessing the next page with this convenient property. Quickly move forward in your document viewing or processing tasks. |
page_count | int | r | Retrieve the total number of pages in your DjVu image collection with this property. Ideal for quickly assessing the extent of your document or book stored in DjVu format. Improve your workflow efficiency with accurate page count information. |
pages | Image[] | r | Access the individual pages of your DjVu image collection with this property. Simplify navigation and manipulation of your document or book stored in DjVu format by accessing each page directly. Improve your workflow efficiency with easy page retrieval. |
palette | IColorPalette | r/w | Gets or sets the color palette. The color palette is not used when pixels are represented directly. |
premultiply_components | bool | r/w | Gets or sets a value indicating whether the image components must be premultiplied. |
previous_page | DjvuPage | r | Quickly move backward in your DjVu document viewing or processing tasks by accessing the previous page with this convenient property. Efficiently navigate through your document with ease. |
raw_custom_color_converter | IColorConverter | r/w | Gets or sets the custom color converter |
raw_data_format | PixelDataFormat | r | Gets the raw data format. |
raw_data_settings | RawDataSettings | r | Gets the current raw data settings. Note when using these settings the data loads without conversion. |
raw_fallback_index | int | r/w | Gets or sets the fallback index to use when palette index is out of bounds |
raw_indexed_color_converter | IIndexedColorConverter | r/w | Gets or sets the indexed color converter |
raw_line_size | int | r | Gets the raw line size in bytes. |
size | Size | r | Gets the object size. |
transparent_color | Color | r/w | Gets the image transparent color. |
update_xmp_data | bool | r/w | Gets or sets a value indicating whether to update the XMP metadata. |
use_palette | bool | r | Gets a value indicating whether the image palette is used. |
use_raw_data | bool | r/w | Gets or sets a value indicating whether to use raw data loading when the raw data loading is available. |
vertical_resolution | double | r/w | Gets or sets the vertical resolution, in pixels per inch, of this RasterImage. |
width | int | r | Gets the image width. |
xmp_data | XmpPacketWrapper | r/w | Gets or sets XMP data from frame. |
Methods
Name | Description |
---|---|
adjust_brightness(brightness) | Adjust the brightness of an image using a specified parameter, providing control over luminance levels for optimal visual clarity. This method enhances or diminishes the overall brightness of the image, allowing for fine adjustments to achieve desired lighting effects. By modulating brightness, users can optimize image visibility and enhance detail reproduction for improved viewing experience. |
adjust_contrast(contrast) | Enhance Image contrast to improve visual clarity and highlight details with this method, which adjusts the difference in brightness between light and dark areas. By fine-tuning contrast levels, users can achieve more vivid and impactful images, enhancing overall image quality and maximizing detail visibility. This adjustment helps to bring out subtle nuances in color and texture, resulting in more dynamic and visually appealing images. |
adjust_gamma(gamma) | Gamma correction, specifically for the red, green, and blue channels, involves adjusting the brightness of each color component separately. By applying different gamma coefficients to the RGB channels, you can fine-tune the overall brightness and contrast of an image. This technique ensures accurate color representation and improves the visual quality of the image across different display devices. |
adjust_gamma(gamma_red, gamma_green, gamma_blue) | Gamma correction is applied to an image with customizable parameters for the red, green, and blue channels, allowing precise adjustment of color balance and brightness. This method enhances image quality by fine-tuning color representation, ensuring optimal rendering across different display devices. Adjusting gamma values for individual channels improves color balance and visual appeal. |
binarize_bradley(brightness_difference) | Binarization of an image using Bradley’s adaptive thresholding algorithm using the integral image thresholding |
binarize_bradley(brightness_difference, window_size) | Binarization using Bradley’s adaptive thresholding algorithm with integral image thresholding is a method that calculates a local threshold for each pixel based on a local neighborhood. It adapts to variations in illumination across the image, making it suitable for images with uneven lighting conditions. By computing the threshold using integral images, it efficiently handles large neighborhoods, making it applicable to real-time applications. This technique is commonly used in document processing, OCR (Optical Character Recognition), and image segmentation tasks where accurate binarization is essential for subsequent analysis. |
binarize_fixed(threshold) | Binarization with a predefined threshold simplifies complex images into binary representations, where pixels are categorized as either black or white based on their intensity compared to a specified threshold value. This technique is commonly used in image processing to enhance clarity, simplify analysis, and prepare images for further processing steps such as optical character recognition (OCR). By applying a fixed threshold, you can quickly transform grayscale images into binary form, making them easier to interpret and extract meaningful information from. |
binarize_otsu() | Binarization using Otsu thresholding is a technique that automatically calculates an optimal threshold value based on the image’s histogram. It separates the image into foreground and background by minimizing the intra-class variance. Otsu’s method is widely used for segmenting images into binary form, particularly when the distribution of pixel intensities is bimodal or multimodal. This approach is beneficial for tasks such as object detection, image segmentation, and feature extraction, where accurate delineation between foreground and background is crucial. |
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() | Cache the data privately to optimize performance and reduce the need for repeated data retrieval from external sources. This approach also helps conserve resources, particularly in scenarios where data access is frequent or resources are limited. |
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. |
create(files) | Creates the specified files. |
create(files, throw_exception_on_load_error) | Creates the specified files. |
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. |
create(multipage_create_options) | Creates the specified multipage create options. |
crop(left_shift, right_shift, top_shift, bottom_shift) | Crop with shifts allows you to precisely adjust the position and dimensions of the cropped area within an image. This feature is invaluable for refining compositions, aligning elements, and emphasizing focal points in your visuals. By incorporating shifts into the cropping process, you can achieve pixel-perfect precision and fine-tune the framing of your images with ease. |
crop(rectangle) | “Crop” trims your image to focus on specific details or remove unwanted elements, enhancing its composition and visual impact. Whether you’re adjusting photos for social media, creating website banners, or designing print materials, this tool helps you refine your images with precision and clarity. |
dither(dithering_method, bits_count) | Performs dithering on the current image. |
dither(dithering_method, bits_count, custom_palette) | The “Dither” function applies a dithering effect to your image, enhancing its visual quality by reducing banding and improving color transitions. Whether you’re working on digital art, photography, or graphic design projects, this feature adds a professional touch to your images, making them appear smoother and more refined. |
filter(rectangle, options) | Apply filters to a specified rectangular area within the image to enhance or modify its appearance. By targeting specific regions, this method allows for precise adjustments, such as blurring, sharpening, or applying artistic effects, to achieve desired visual outcomes. Fine-tuning filters on selected areas empowers users to customize image aesthetics, improve clarity, and create artistic effects tailored to their preferences. |
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() | Gets the options based on the original file settings. 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() | Grayscale transformation converts an image to a black-and-white representation, where each pixel’s intensity is represented by a single value ranging from black to white. This process removes color information, resulting in a monochromatic image. Grayscale images are commonly used in applications where color is unnecessary or where simplicity is preferred, such as document scanning, printing, and certain types of image analysis. |
load(file_path) | Loads a new image from the specified file path or URL. If filePath is a file path the method just opens the file. If filePath is an URL, the method downloads the file, stores it as a temporary one, and opens it. |
load(file_path, load_options) | Loads a new image from the specified file path or URL. If filePath is a file path the method just opens the file. If filePath is an URL, the method downloads the file, stores it as a temporary one, and opens it. |
load(stream) | Load your DjVu document with this method. Streamline your process by quickly accessing and importing your DjVu files into your application. |
load(stream, load_options) | Import your DjVu document by utilizing this method with stream and loadOptions parameters. Streamline your process by quickly accessing and importing DjVu files into your application, providing flexibility and customization options to meet your needs. |
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_document(stream) | Load your DjVu document with this method. Streamline your process by quickly accessing and importing your DjVu files into your application. |
load_document(stream, load_options) | Import your DjVu document by utilizing this method with stream and loadOptions parameters. Streamline your process by quickly accessing and importing DjVu files into your application, providing flexibility and customization options to meet your needs. |
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 path or URL. If filePath is a file path the method just opens the file. If filePath is an URL, the method downloads the file, stores it as a temporary one, and opens it. |
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. |
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_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_height_proportionally(new_height) | Resizes the height proportionally. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used. |
resize_height_proportionally(new_height, resize_type) | The ResizeHeightProportionally method allows you to adjust the height of yourimage while preserving its aspect ratio. This ensures that your image maintains its proportions, preventing distortion and preserving its visual integrity. Whether you’re optimizing images for web pages, mobile apps, or print media, this method ensures that your images look their best across different platforms and devices. |
resize_height_proportionally(new_height, settings) | Resizes the height proportionally. |
resize_height_proportionally_settings(new_height, settings) | Resizes the height proportionally. |
resize_width_proportionally(new_width) | Resizes the width proportionally. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used. |
resize_width_proportionally(new_width, resize_type) | The ResizeWidthProportionally method offers a convenient solution to adjust thewidth of your image while maintaining its aspect ratio. By proportionally resizing the width, you can ensure that your images remain visually appealing and consistent across different devices and screen sizes, enhancing their versatility and usability in various contexts. |
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) | Rotate the image around its center with the Rotate method of the RasterCachedMultipageImage class. This convenient feature allows you to easily adjust the orientation of images while maintaining their center position, enhancing your image manipulation capabilities. |
rotate_flip(rotate_flip_type) | The RotateFlip method offers versatile manipulation options for your image, allowingyou to rotate, flip, or perform both operations on the active frame independently. Whether you’re editing photos, creating graphics, or enhancing digital art, this method provides precise control over the orientation and composition of your images, ensuring they meet your creative vision with ease and efficiency. |
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 data. |
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 pixels (format specific method). |
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_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: DjvuImage(stream)
DjvuImage(stream)
Start working with DjVu images by initializing a new instance of the
DjvuImage class using a Stream parameter. Perfect for
developers who want seamless integration of DjVu image processing into
their projects.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream. |
Constructor: DjvuImage(stream, load_options)
DjvuImage(stream, load_options)
Start working with DjVu images seamlessly with this constructor, which
initializes a new DjvuImage class instance using a Stream and
LoadOptions parameters. Perfect for developers who want precise control over
DjVu image loading options while maintaining simplicity and efficiency.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to load from. |
load_options | LoadOptions | The load options. |
Method: adjust_brightness(brightness)
adjust_brightness(brightness)
Adjust the brightness of an image using a specified parameter,
providing control over luminance levels for optimal visual clarity. This method enhances
or diminishes the overall brightness of the image, allowing for fine adjustments to
achieve desired lighting effects. By modulating brightness, users can optimize image
visibility and enhance detail reproduction for improved viewing experience.
Parameters:
Parameter | Type | Description |
---|---|---|
brightness | int | Brightness value. |
See also:
Example # 1: The following example performs brightness correction of a DJVU image.
Method: adjust_contrast(contrast)
adjust_contrast(contrast)
Enhance Image contrast to improve visual clarity and
highlight details with this method, which adjusts the difference in brightness between
light and dark areas. By fine-tuning contrast levels, users can achieve more vivid and
impactful images, enhancing overall image quality and maximizing detail visibility.
This adjustment helps to bring out subtle nuances in color and texture, resulting in
more dynamic and visually appealing images.
Parameters:
Parameter | Type | Description |
---|---|---|
contrast | float | Contrast value (in range [-100; 100]) |
See also:
Example # 1: The following example performs contrast correction of a DJVU image.
Method: adjust_gamma(gamma)
adjust_gamma(gamma)
Gamma correction, specifically for the red, green, and blue channels, involves adjusting
the brightness of each color component separately. By applying different gamma
coefficients to the RGB channels, you can fine-tune the overall brightness and contrast
of an image. This technique ensures accurate color representation and improves the
visual quality of the image across different display devices.
Parameters:
Parameter | Type | Description |
---|---|---|
gamma | float | Gamma for red, green and blue channels coefficient |
See also:
Example # 1: The following example performs gamma-correction of a DJVU image.
Method: adjust_gamma(gamma_red, gamma_green, gamma_blue)
adjust_gamma(gamma_red, gamma_green, gamma_blue)
Gamma correction is applied to an image with customizable parameters for the red, green,
and blue channels, allowing precise adjustment of color balance and brightness. This
method enhances image quality by fine-tuning color representation, ensuring optimal
rendering across different display devices. Adjusting gamma values for individual
channels improves color balance and visual appeal.
Parameters:
Parameter | Type | Description |
---|---|---|
gamma_red | float | Gamma for red channel coefficient |
gamma_green | float | Gamma for green channel coefficient |
gamma_blue | float | Gamma for blue channel coefficient |
See also:
Example # 1: The following example performs gamma-correction of a DJVU image applying diff…
Method: binarize_bradley(brightness_difference)
binarize_bradley(brightness_difference)
Binarization of an image using Bradley’s adaptive thresholding algorithm using the integral image thresholding
Parameters:
Parameter | Type | Description |
---|---|---|
brightness_difference | double | The 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 using Bradley’s adaptive thresholding algorithm with integral image
thresholding is a method that calculates a local threshold for each pixel based on a
local neighborhood. It adapts to variations in illumination across the image, making it
suitable for images with uneven lighting conditions. By computing the threshold using
integral images, it efficiently handles large neighborhoods, making it applicable to
real-time applications. This technique is commonly used in document processing, OCR
(Optical Character Recognition), and image segmentation tasks where accurate
binarization is essential for subsequent analysis.
Parameters:
Parameter | Type | Description |
---|---|---|
brightness_difference | double | The brightness difference between pixel and the average of an s x s window of pixels centered around this pixel. |
window_size | int | The size of s x s window of pixels centered around this pixel |
Method: binarize_fixed(threshold)
binarize_fixed(threshold)
Binarization with a predefined threshold simplifies complex images into binary
representations, where pixels are categorized as either black or white based on their
intensity compared to a specified threshold value. This technique is commonly used in
image processing to enhance clarity, simplify analysis, and prepare images for further
processing steps such as optical character recognition (OCR). By applying a fixed
threshold, you can quickly transform grayscale images into binary form, making them
easier to interpret and extract meaningful information from.
Parameters:
Parameter | Type | Description |
---|---|---|
threshold | byte | Threshold value. If corresponding gray value of a pixel is greater than threshold, a value of 255 will be assigned to it, 0 otherwise. |
See also:
Example # 1: The following example binarizes a DJVU image with the predefined threshold. B…
Method: blend(origin, overlay, overlay_alpha)
blend(origin, overlay, overlay_alpha)
Blends this image instance with the overlay image.
Parameters:
Parameter | Type | Description |
---|---|---|
origin | Point | The background image blending origin. |
overlay | RasterImage | The overlay image. |
overlay_alpha | byte | The 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:
Parameter | Type | Description |
---|---|---|
origin | Point | The background image blending origin. |
overlay | RasterImage | The overlay image. |
overlay_area | Rectangle | The overlay area. |
overlay_alpha | byte | The overlay alpha. |
Method: can_load(file_path) [static]
can_load(file_path)
Determines whether image can be loaded from the specified file path.
Parameters:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path. |
Returns
Type | Description |
---|---|
bool |
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:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path. |
load_options | LoadOptions | The load options. |
Returns
Type | Description |
---|---|
bool |
Method: can_load(stream) [static]
can_load(stream)
Determines whether image can be loaded from the specified stream.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to load from. |
Returns
Type | Description |
---|---|
bool |
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:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to load from. |
load_options | LoadOptions | The load options. |
Returns
Type | Description |
---|---|
bool |
Method: can_load_stream(stream) [static]
can_load_stream(stream)
Determines whether image can be loaded from the specified stream.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to load from. |
Returns
Type | Description |
---|---|
bool |
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:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to load from. |
load_options | LoadOptions | The load options. |
Returns
Type | Description |
---|---|
bool |
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:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path. |
load_options | LoadOptions | The load options. |
Returns
Type | Description |
---|---|
bool |
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:
Parameter | Type | Description |
---|---|---|
options | ImageOptionsBase | The save options to use. |
Returns
Type | Description |
---|---|
bool |
Method: create(files) [static]
create(files)
Creates the specified files.
Parameters:
Parameter | Type | Description |
---|---|---|
files | string | The files. |
Returns
Type | Description |
---|---|
Image | The multipage image |
Method: create(files, throw_exception_on_load_error) [static]
create(files, throw_exception_on_load_error)
Creates the specified files.
Parameters:
Parameter | Type | Description |
---|---|---|
files | string | The files. |
throw_exception_on_load_error | bool | if set to |
Returns
Type | Description |
---|---|
Image | The multipage image |
Method: create(image_options, width, height) [static]
create(image_options, width, height)
Creates a new image using the specified create options.
Parameters:
Parameter | Type | Description |
---|---|---|
image_options | ImageOptionsBase | The image options. |
width | int | The width. |
height | int | The height. |
Returns
Type | Description |
---|---|
Image | The newly created image. |
Method: create(images) [static]
create(images)
Creates a new image using the specified images as pages
Parameters:
Parameter | Type | Description |
---|---|---|
images | Image[] | The images. |
Returns
Type | Description |
---|---|
Image | The Image as IMultipageImage |
Method: create(images, dispose_images) [static]
create(images, dispose_images)
Creates a new image the specified images as pages.
Parameters:
Parameter | Type | Description |
---|---|---|
images | Image[] | The images. |
dispose_images | bool | if set to |
Returns
Type | Description |
---|---|
Image | The Image as IMultipageImage |
Method: create(multipage_create_options) [static]
create(multipage_create_options)
Creates the specified multipage create options.
Parameters:
Parameter | Type | Description |
---|---|---|
multipage_create_options | MultipageCreateOptions | The multipage create options. |
Returns
Type | Description |
---|---|
Image | The multipage image |
Method: crop(left_shift, right_shift, top_shift, bottom_shift)
crop(left_shift, right_shift, top_shift, bottom_shift)
Crop with shifts allows you to precisely adjust the position and dimensions of the
cropped area within an image. This feature is invaluable for refining compositions,
aligning elements, and emphasizing focal points in your visuals. By incorporating shifts
into the cropping process, you can achieve pixel-perfect precision and fine-tune the
framing of your images with ease.
Parameters:
Parameter | Type | Description |
---|---|---|
left_shift | int | The left shift. |
right_shift | int | The right shift. |
top_shift | int | The top shift. |
bottom_shift | int | The bottom shift. |
Method: crop(rectangle)
crop(rectangle)
“Crop” trims your image to focus on specific details or remove unwanted elements,
enhancing its composition and visual impact. Whether you’re adjusting photos for social
media, creating website banners, or designing print materials, this tool helps you
refine your images with precision and clarity.
Parameters:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle. |
See also:
Example # 1: The following example crops a DJVU image. The cropping area is be specified v…
Method: dither(dithering_method, bits_count)
dither(dithering_method, bits_count)
Performs dithering on the current image.
Parameters:
Parameter | Type | Description |
---|---|---|
dithering_method | DitheringMethod | The dithering method. |
bits_count | int | The final bits count for dithering. |
Method: dither(dithering_method, bits_count, custom_palette)
dither(dithering_method, bits_count, custom_palette)
The “Dither” function applies a dithering effect to your image, enhancing its visual
quality by reducing banding and improving color transitions. Whether you’re working
on digital art, photography, or graphic design projects, this feature adds a
professional touch to your images, making them appear smoother and more refined.
Parameters:
Parameter | Type | Description |
---|---|---|
dithering_method | DitheringMethod | The dithering method. |
bits_count | int | The final bits count for dithering. |
custom_palette | IColorPalette | The custom palette for dithering. |
Method: filter(rectangle, options)
filter(rectangle, options)
Apply filters to a specified rectangular area within the image to enhance or modify its
appearance. By targeting specific regions, this method allows for precise adjustments,
such as blurring, sharpening, or applying artistic effects, to achieve desired visual
outcomes. Fine-tuning filters on selected areas empowers users to customize image
aesthetics, improve clarity, and create artistic effects tailored to their preferences.
Parameters:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle. |
options | FilterOptionsBase | The options. |
Method: get_argb_32_pixel(x, y)
get_argb_32_pixel(x, y)
Gets an image 32-bit ARGB pixel.
Parameters:
Parameter | Type | Description |
---|---|---|
x | int | The pixel x location. |
y | int | The pixel y location. |
Returns
Type | Description |
---|---|
int | The 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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to get pixels for. |
Returns
Type | Description |
---|---|
int | The default pixels array. |
Method: get_default_options(args)
get_default_options(args)
Gets the default options.
Parameters:
Parameter | Type | Description |
---|---|---|
args | object | The arguments. |
Returns
Type | Description |
---|---|
ImageOptionsBase | Default 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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to get pixels for. |
partial_pixel_loader | IPartialArgb32PixelLoader | The 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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to get pixels for. |
partial_raw_data_loader | IPartialRawDataLoader | The partial raw data loader. |
raw_data_settings | RawDataSettings | The 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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to get raw data for. |
raw_data_settings | RawDataSettings | The raw data settings. |
Returns
Type | Description |
---|---|
byte | The default raw data array. |
Method: get_file_format(file_path) [static]
get_file_format(file_path)
Gets the file format.
Parameters:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path. |
Returns
Type | Description |
---|---|
FileFormat | The determined file format. |
Method: get_file_format(stream) [static]
get_file_format(stream)
Gets the file format.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream. |
Returns
Type | Description |
---|---|
FileFormat | The determined file format. |
Method: get_file_format_of_stream(stream) [static]
get_file_format_of_stream(stream)
Gets the file format.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream. |
Returns
Type | Description |
---|---|
FileFormat | The 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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to get fitting rectangle for. |
pixels | int | The 32-bit ARGB pixels. |
width | int | The object width. |
height | int | The object height. |
Returns
Type | Description |
---|---|
Rectangle | The 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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to get fitting rectangle for. |
width | int | The object width. |
height | int | The object height. |
Returns
Type | Description |
---|---|
Rectangle | The 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:
Parameter | Type | Description |
---|---|---|
use_default | bool | if set to |
Returns
Type | Description |
---|---|
datetime | The date and time the resource image was last modified. |
Method: get_original_options()
get_original_options()
Gets the options based on the original file settings.
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
Type | Description |
---|---|
ImageOptionsBase | The options based on the original file settings. |
Method: get_pixel(x, y)
get_pixel(x, y)
Gets an image pixel.
Parameters:
Parameter | Type | Description |
---|---|---|
x | int | The pixel x location. |
y | int | The pixel y location. |
Returns
Type | Description |
---|---|
Color | The 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:
Parameter | Type | Description |
---|---|---|
width | int | The width. |
height | int | The height. |
new_width | int | The new width. |
Returns
Type | Description |
---|---|
int | The proportional height. |
Method: get_proportional_width(width, height, new_height) [static]
get_proportional_width(width, height, new_height)
Gets a proportional width.
Parameters:
Parameter | Type | Description |
---|---|---|
width | int | The width. |
height | int | The height. |
new_height | int | The new height. |
Returns
Type | Description |
---|---|
int | The 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:
Parameter | Type | Description |
---|---|---|
image_options | ImageOptionsBase | The image options. |
clipping_rectangle | Rectangle | The clipping rectangle. |
page_number | int[] | The page number. |
Returns
Type | Description |
---|---|
_io.BufferedRandom | The 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
Type | Description |
---|---|
float | The skew angle, in degrees. |
Method: load(file_path) [static]
load(file_path)
Loads a new image from the specified file path or URL.
If filePath is a file path the method just opens the file.
If filePath is an URL, the method downloads the file, stores it as a temporary one, and opens it.
Parameters:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path or URL to load image from. |
Returns
Type | Description |
---|---|
Image | The loaded image. |
Method: load(file_path, load_options) [static]
load(file_path, load_options)
Loads a new image from the specified file path or URL.
If filePath is a file path the method just opens the file.
If filePath is an URL, the method downloads the file, stores it as a temporary one, and opens it.
Parameters:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path or URL to load image from. |
load_options | LoadOptions | The load options. |
Returns
Type | Description |
---|---|
Image | The loaded image. |
Method: load(stream) [static]
load(stream)
Load your DjVu document with this method. Streamline your process by quickly
accessing and importing your DjVu files into your application.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream. |
Returns
Type | Description |
---|---|
Image | Loaded djvu document |
Method: load(stream, load_options) [static]
load(stream, load_options)
Import your DjVu document by utilizing this method with stream and loadOptions
parameters. Streamline your process by quickly accessing and importing DjVu files
into your application, providing flexibility and customization options to meet
your needs.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream. |
load_options | LoadOptions | The load options. |
Returns
Type | Description |
---|---|
Image | Loaded djvu document |
Method: load_argb_32_pixels(rectangle)
load_argb_32_pixels(rectangle)
Loads 32-bit ARGB pixels.
Parameters:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to load pixels from. |
Returns
Type | Description |
---|---|
int | The loaded 32-bit ARGB pixels array. |
Method: load_argb_64_pixels(rectangle)
load_argb_64_pixels(rectangle)
Loads 64-bit ARGB pixels.
Parameters:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to load pixels from. |
Returns
Type | Description |
---|---|
long | The loaded 64-bit ARGB pixels array. |
Method: load_cmyk_32_pixels(rectangle)
load_cmyk_32_pixels(rectangle)
Loads pixels in CMYK format.
Parameters:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to load pixels from. |
Returns
Type | Description |
---|---|
int | The 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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to load pixels from. |
Returns
Type | Description |
---|---|
CmykColor[] | The loaded CMYK pixels array. |
Method: load_document(stream) [static]
load_document(stream)
Load your DjVu document with this method. Streamline your process by quickly
accessing and importing your DjVu files into your application.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream. |
Returns
Type | Description |
---|---|
DjvuImage | Loaded djvu document |
Method: load_document(stream, load_options) [static]
load_document(stream, load_options)
Import your DjVu document by utilizing this method with stream and loadOptions
parameters. Streamline your process by quickly accessing and importing DjVu files
into your application, providing flexibility and customization options to meet
your needs.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream. |
load_options | LoadOptions | The load options. |
Returns
Type | Description |
---|---|
DjvuImage | Loaded djvu document |
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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to load pixels from. |
partial_pixel_loader | IPartialArgb32PixelLoader | The 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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The desired rectangle. |
partial_pixel_loader | IPartialArgb64PixelLoader | The 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:
Parameter | Type | Description |
---|---|---|
desired_rectangle | Rectangle | The desired rectangle. |
pixel_loader | IPartialPixelLoader | The pixel loader. |
Method: load_pixels(rectangle)
load_pixels(rectangle)
Loads pixels.
Parameters:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to load pixels from. |
Returns
Type | Description |
---|---|
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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to load raw data from. |
dest_image_bounds | Rectangle | The dest image bounds. |
raw_data_settings | RawDataSettings | The 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_loader | IPartialRawDataLoader | The 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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to load raw data from. |
raw_data_settings | RawDataSettings | The 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_loader | IPartialRawDataLoader | The raw data loader. |
Method: load_stream(stream) [static]
load_stream(stream)
Loads a new image from the specified stream.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to load image from. |
Returns
Type | Description |
---|---|
Image | The 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:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to load image from. |
load_options | LoadOptions | The load options. |
Returns
Type | Description |
---|---|
Image | The 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 path or URL.
If filePath is a file path the method just opens the file.
If filePath is an URL, the method downloads the file, stores it as a temporary one, and opens it.
Parameters:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path or URL to load image from. |
load_options | LoadOptions | The load options. |
Returns
Type | Description |
---|---|
Image | The 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:
Parameter | Type | Description |
---|---|---|
resize_proportionally | bool | if set to |
background_color | Color | Color 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:
Parameter | Type | Description |
---|---|---|
scan_line_index | int | Zero based index of the scan line. |
Returns
Type | Description |
---|---|
int | The 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:
Parameter | Type | Description |
---|---|---|
scan_line_index | int | Zero based index of the scan line. |
Returns
Type | Description |
---|---|
Color[] | The scan line pixel color values array. |
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:
Parameter | Type | Description |
---|---|---|
old_color_argb | int | Old color ARGB value to be replaced. |
old_color_diff | byte | Allowed difference in old color to be able to widen replaced color tone. |
new_color_argb | int | New 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:
Parameter | Type | Description |
---|---|---|
old_color | Color | |
old_color_diff | byte | Allowed difference in old color to be able to widen replaced color tone. |
new_color | Color |
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:
Parameter | Type | Description |
---|---|---|
old_color_argb | int | Old color ARGB value to be replaced. |
old_color_diff | byte | Allowed difference in old color to be able to widen replaced color tone. |
new_color_argb | int | New 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:
Parameter | Type | Description |
---|---|---|
new_color | Color |
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:
Parameter | Type | Description |
---|---|---|
new_color_argb | int | New 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:
Parameter | Type | Description |
---|---|---|
new_width | int | The new width. |
new_height | int | The new height. |
Method: resize(new_width, new_height, resize_type)
resize(new_width, new_height, resize_type)
Resizes the image.
Parameters:
Parameter | Type | Description |
---|---|---|
new_width | int | The new width. |
new_height | int | The new height. |
resize_type | ResizeType | The resize type. |
Method: resize(new_width, new_height, settings)
resize(new_width, new_height, settings)
Resizes the image.
Parameters:
Parameter | Type | Description |
---|---|---|
new_width | int | The new width. |
new_height | int | The new height. |
settings | ImageResizeSettings | The resize settings. |
Method: resize_by_settings(new_width, new_height, settings)
resize_by_settings(new_width, new_height, settings)
Resizes the image.
Parameters:
Parameter | Type | Description |
---|---|---|
new_width | int | The new width. |
new_height | int | The new height. |
settings | ImageResizeSettings | The 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:
Parameter | Type | Description |
---|---|---|
new_width | int | The new width. |
new_height | int | The new height. |
resize_type | ResizeType | The 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:
Parameter | Type | Description |
---|---|---|
new_height | int | The new height. |
Method: resize_height_proportionally(new_height, resize_type)
resize_height_proportionally(new_height, resize_type)
The ResizeHeightProportionally
method allows you to adjust the height of your
image while preserving its aspect ratio. This ensures that your image maintains
its proportions, preventing distortion and preserving its visual integrity.
Whether you’re optimizing images for web pages, mobile apps, or print media, this
method ensures that your images look their best across different platforms and devices.
Parameters:
Parameter | Type | Description |
---|---|---|
new_height | int | The new height. |
resize_type | ResizeType | Type of the resize. |
Method: resize_height_proportionally(new_height, settings)
resize_height_proportionally(new_height, settings)
Resizes the height proportionally.
Parameters:
Parameter | Type | Description |
---|---|---|
new_height | int | The new height. |
settings | ImageResizeSettings | The image resize settings. |
Method: resize_height_proportionally_settings(new_height, settings)
resize_height_proportionally_settings(new_height, settings)
Resizes the height proportionally.
Parameters:
Parameter | Type | Description |
---|---|---|
new_height | int | The new height. |
settings | ImageResizeSettings | The image resize settings. |
Method: resize_width_proportionally(new_width)
resize_width_proportionally(new_width)
Resizes the width proportionally. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.
Parameters:
Parameter | Type | Description |
---|---|---|
new_width | int | The new width. |
Method: resize_width_proportionally(new_width, resize_type)
resize_width_proportionally(new_width, resize_type)
The ResizeWidthProportionally
method offers a convenient solution to adjust the
width of your image while maintaining its aspect ratio. By proportionally resizing
the width, you can ensure that your images remain visually appealing and
consistent across different devices and screen sizes, enhancing their versatility
and usability in various contexts.
Parameters:
Parameter | Type | Description |
---|---|---|
new_width | int | The new width. |
resize_type | ResizeType | Type of the resize. |
Method: resize_width_proportionally(new_width, settings)
resize_width_proportionally(new_width, settings)
Resizes the width proportionally.
Parameters:
Parameter | Type | Description |
---|---|---|
new_width | int | The new width. |
settings | ImageResizeSettings | The image resize settings. |
Method: resize_width_proportionally_settings(new_width, settings)
resize_width_proportionally_settings(new_width, settings)
Resizes the width proportionally.
Parameters:
Parameter | Type | Description |
---|---|---|
new_width | int | The new width. |
settings | ImageResizeSettings | The image resize settings. |
Method: rotate(angle)
rotate(angle)
Rotate image around the center.
Parameters:
Parameter | Type | Description |
---|---|---|
angle | float | The rotate angle in degrees. Positive values will rotate clockwise. |
Method: rotate(angle, resize_proportionally, background_color)
rotate(angle, resize_proportionally, background_color)
Rotate the image around its center with the Rotate method of the
RasterCachedMultipageImage class. This convenient feature allows you to easily
adjust the orientation of images while maintaining their center position,
enhancing your image manipulation capabilities.
Parameters:
Parameter | Type | Description |
---|---|---|
angle | float | The rotate angle in degrees. Positive values will rotate clockwise. |
resize_proportionally | bool | if set to according to rotated rectangle (corner points) projections in other case that leaves dimensions untouched and only internal image contents are rotated. |
background_color | Color | Color of the background. |
Method: rotate_flip(rotate_flip_type)
rotate_flip(rotate_flip_type)
The RotateFlip
method offers versatile manipulation options for your image, allowing
you to rotate, flip, or perform both operations on the active frame independently.
Whether you’re editing photos, creating graphics, or enhancing digital art, this
method provides precise control over the orientation and composition of your images,
ensuring they meet your creative vision with ease and efficiency.
Parameters:
Parameter | Type | Description |
---|---|---|
rotate_flip_type | RotateFlipType | The rotate flip type. |
Method: rotate_flip_all(rotate_flip)
rotate_flip_all(rotate_flip)
Rotates the flip all.
Parameters:
Parameter | Type | Description |
---|---|---|
rotate_flip | RotateFlipType | The rotate flip. |
Method: save(file_path)
save(file_path)
Saves the image to the specified file location.
Parameters:
Parameter | Type | Description |
---|---|---|
file_path | string | The 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:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path. |
options | ImageOptionsBase | The 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:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path. |
options | ImageOptionsBase | The options. |
bounds_rectangle | Rectangle | The 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:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path to save the object’s data to. |
over_write | bool | if set to |
Method: save(stream)
save(stream)
Saves the data.
Parameters:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to save 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:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to save the image’s data to. |
options_base | ImageOptionsBase | The 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:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to save the image’s data to. |
options_base | ImageOptionsBase | The save options. |
bounds_rectangle | Rectangle | The 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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to save pixels to. |
pixels | int | The 32-bit ARGB pixels array. |
Method: save_cmyk_32_pixels(rectangle, pixels)
save_cmyk_32_pixels(rectangle, pixels)
Saves the pixels.
Parameters:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to save pixels to. |
pixels | int | The 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:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to save pixels to. |
pixels | CmykColor[] | The CMYK pixels array. |
Method: save_pixels(rectangle, pixels)
save_pixels(rectangle, pixels)
Saves pixels (format specific method).
Parameters:
Parameter | Type | Description |
---|---|---|
rectangle | Rectangle | The rectangle to save pixels to. |
pixels | Color[] | The 32-bit ARGB pixels array. |
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:
Parameter | Type | Description |
---|---|---|
data | byte | The raw data. |
data_offset | int | The starting raw data offset. |
rectangle | Rectangle | The raw data rectangle. |
raw_data_settings | RawDataSettings | The 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:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The 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:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to save the image’s data to. |
options_base | ImageOptionsBase | The 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:
Parameter | Type | Description |
---|---|---|
stream | _io.BufferedRandom | The stream to save the image’s data to. |
options_base | ImageOptionsBase | The save options. |
bounds_rectangle | Rectangle | The 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:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path. |
options | ImageOptionsBase | The 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:
Parameter | Type | Description |
---|---|---|
file_path | string | The file path. |
options | ImageOptionsBase | The options. |
bounds_rectangle | Rectangle | The 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:
Parameter | Type | Description |
---|---|---|
x | int | The pixel x location. |
y | int | The pixel y location. |
argb_32_color | int | The 32-bit ARGB pixel for the specified position. |
Method: set_palette(palette, update_colors)
set_palette(palette, update_colors)
Sets the image palette.
Parameters:
Parameter | Type | Description |
---|---|---|
palette | IColorPalette | The palette to set. |
update_colors | bool | if set to |
Method: set_pixel(x, y, color)
set_pixel(x, y, color)
Sets an image pixel for the specified position.
Parameters:
Parameter | Type | Description |
---|---|---|
x | int | The pixel x location. |
y | int | The pixel y location. |
color | Color | The 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:
Parameter | Type | Description |
---|---|---|
dpi_x | double | The horizontal resolution, in dots per inch, of the RasterImage. |
dpi_y | double | The 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:
Parameter | Type | Description |
---|---|---|
scan_line_index | int | Zero based index of the scan line. |
argb_32_pixels | int | The 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:
Parameter | Type | Description |
---|---|---|
scan_line_index | int | Zero based index of the scan line. |
pixels | Color[] | The pixel colors array to write. |
Examples
The following example crops a DJVU image. The cropping area is be specified via aspose.imaging.Rectangle.
from aspose.pycore import as_of
from aspose.imaging import Image, Rectangle
from aspose.imaging.fileformats.djvu import DjvuImage
from aspose.imaging.imageoptions import PngOptions
with Image.load("sample.djvu") as image:
djvuImage = as_of(image, DjvuImage)
# Crop the image. The cropping area is the rectangular central area of the image.
area = Rectangle(djvuImage.width // 4, djvuImage.height // 4, djvuImage.width // 2, djvuImage.height // 2)
djvuImage.crop(area)
# Save the cropped image to PNG
djvuImage.save("sample.Crop.png", PngOptions())
The following example binarizes a DJVU image with the predefined threshold. Binarized images contain only 2 colors - black and white.
import aspose.pycore as aspycore
from aspose.imaging import Image
from aspose.imaging.fileformats.djvu import DjvuImage
from aspose.imaging.imageoptions import PngOptions
from os.path import join
dir_ = "c:\\temp"
with Image.load(join(dir_, "sample.djvu")) as image:
djvu_image = aspycore.as_of(image, DjvuImage)
# Binarize the image with a threshold value of 127.
# If a corresponding gray value of a pixel is greater than 127, a value of 255 will be assigned to it, 0 otherwise.
djvu_image.binarize_fixed(127)
djvu_image.save(join(dir_, "sample.BinarizeFixed.png"), PngOptions())
The following example performs gamma-correction of a DJVU image.
import aspose.pycore as aspycore
from aspose.imaging import Image
from aspose.imaging.fileformats.djvu import DjvuImage
from aspose.imaging.imageoptions import PngOptions
from os.path import join
dir_: str = "c:\\temp"
with Image.load(join(dir_, "sample.djvu")) as image:
djvu_image = aspycore.as_of(image, DjvuImage)
# Set gamma coefficient for red, green and blue channels.
djvu_image.adjust_gamma(2.5)
djvu_image.save(join(dir_, "sample.AdjustGamma.png"), PngOptions())
The following example performs gamma-correction of a DJVU image applying different coefficients for color components.
import aspose.pycore as aspycore
from aspose.imaging import Image
from aspose.imaging.fileformats.djvu import DjvuImage
from aspose.imaging.imageoptions import PngOptions
from os.path import join
dir_ = "c:\\temp"
with Image.load(join(dir_, "sample.djvu")) as image:
djvu_image = aspycore.as_of(image, DjvuImage)
# Set individual gamma coefficients for red, green and blue channels.
djvu_image.adjust_gamma(1.5, 2.5, 3.5)
djvu_image.save(join(dir_, "sample.AdjustGamma.png"), PngOptions())
The following example performs brightness correction of a DJVU image.
import aspose.pycore as aspycore
from aspose.imaging import Image
from aspose.imaging.fileformats.djvu import DjvuImage
from aspose.imaging.imageoptions import PngOptions
from os.path import join
dir_ = "c:\\temp"
with Image.load(join(dir_, "sample.djvu")) as image:
djvu_image = aspycore.as_of(image, DjvuImage)
# Set the brightness value. The accepted values of brightness are in the range [-255, 255].
djvu_image.adjust_brightness(50)
djvu_image.save(join(dir_, "sample.AdjustBrightness.png"), PngOptions())
The following example performs contrast correction of a DJVU image.
import aspose.pycore as aspycore
from aspose.imaging import Image
from aspose.imaging.fileformats.djvu import DjvuImage
from aspose.imaging.imageoptions import PngOptions
from os.path import join
dir_ = "c:\\temp"
with Image.load(join(dir_, "sample.djvu")) as image:
djvu_image = aspycore.as_of(image, DjvuImage)
# Set the contrast value. The accepted values of contrast are in the range [-100f, 100f].
djvu_image.adjust_contrast(50.0)
djvu_image.save(join(dir_, "sample.AdjustContrast.png"), PngOptions())