WebPImage 类
Summary: Manipulate WebP raster images with our API, using its modern features for both
lossless and lossy compression, ensuring optimal image quality with reduced file sizes.
Seamlessly handle extended file formats, animations, and alpha channels, while easily
updating dimensions, resizing proportionally, cropping, rotating, applying filters,
adjusting image parameters, and converting to other image formats for versatile
web image optimization.
Module: aspose.imaging.fileformats.webp
Full Name: aspose.imaging.fileformats.webp.WebPImage
Inheritance: IObjectWithBounds, IMetadataContainer, IHasExifData, IHasMetadata, IHasXmpData, IRasterImageArgb32PixelLoader, IRasterImageRawDataLoader, IMultipageImage, IMultipageImageExt, RasterCachedMultipageImage
Constructors
| Name | 描述 |
|---|---|
| WebPImage(path) | 实例化一个全新的 WebPImage 类,初始化 来自提供的文件源。利用此构造函数可无缝地直接从文件创建 WebP 图像对象,简化在应用程序中加载和 操作 WebP 图像数据的过程。 |
| WebPImage(path, load_options) | 使用文件和 指定的加载选项创建一个新的 WebPImage 类实例,以便灵活处理 WebP 图像数据。利用 此构造函数可无缝地从文件初始化 WebP 图像对象,同时 根据应用程序的需求自定义加载参数。 |
| WebPImage(raster_image) | 实例化一个新的 WebPImage 类实例,初始化 来自提供的 rasterImage 对象。此构造函数允许无缝地 将光栅图像转换为 WebP 格式,从而在应用程序中实现高效的图像数据处理和 操作。 |
| WebPImage(raster_image, load_options) | 使用 rasterImage 对象和 指定的加载选项创建一个新的 WebPImage 类实例,以实现灵活的图像数据处理。利用此 构造函数可无缝地从光栅图像初始化 WebP 图像对象,同时 根据应用程序的需求自定义加载参数。 |
| WebPImage(stream) | 实例化一个新的 WebPImage 类的实例,已初始化 来自提供的流源。利用此构造函数可无缝地直接从流创建 WebP 图像对象,实现对 WebP 图像数据的高效处理和操作 在您的应用程序中。 |
| WebPImage(stream, load_options) | 从流中创建一个新的 WebPImage 类的实例, 并结合指定的加载选项和内存管理设置。此构造函数在从流加载 WebP 图像时提供灵活性,同时 高效管理内存资源,确保最佳性能和资源 在您的应用程序中的利用率。 |
| WebPImage(width, height, options) | 实例化一个新的 WebPImage 类的实例,使用空的 指定宽度和高度的图像。此构造函数允许创建空白 WebP 图像,为后续的图像 操作和内容生成提供基础。 |
| WebPImage(width, height, options, load_options) | 创建一个新的 WebPImage 类的实例,使用空图像并指定 加载选项。此构造函数允许使用可定制的加载参数,为图像创建和 在您的应用程序中的操作提供灵活性。 |
Properties
| Name | Type | Access | 描述 |
|---|---|---|---|
| auto_adjust_palette | bool | r/w | 获取或设置一个值,指示是否自动调整调色板。 |
| background_color | Color | r/w | 获取或设置背景颜色的值。 |
| bits_per_pixel | int | r | 获取图像每像素位数计数。 |
| bounds | Rectangle | r | 获取对象的边界。 |
| buffer_size_hint | int | r/w | 获取或设置缓冲区大小提示,该提示定义了所有内部缓冲区的最大允许大小。 |
| container | Image | r | 获取 Image 容器。 |
| data_stream_container | StreamContainer | r | 获取对象的数据流。 |
| disposed | bool | r | 获取一个值,指示此实例是否已释放。 |
| exif_data | ExifData | r/w | 获取或设置 Exif 实例。 |
| file_format | FileFormat | r | 访问与图像关联的文件格式值,提供关于 图像存储格式的信息。利用此属性确定 图像的文件格式,便于兼容性检查和 在您的应用程序中的特定格式处理。 |
| has_alpha | bool | r | 获取图像是否包含 alpha 通道,以指示 透明度信息的存在。利用此属性确定图像是否 包含透明度,从而实现对 alpha 相关操作的适当处理和处理,在您的应用程序中。 |
| has_background_color | bool | r/w | 获取或设置指示图像是否具有背景颜色的值。 |
| has_transparent_color | bool | r/w | 获取指示图像是否具有透明颜色的值。 |
| height | int | r | 获取图像高度。 |
| horizontal_resolution | float | r/w | 获取或设置此 RasterImage 的水平分辨率(每英寸像素数)。 |
| image_opacity | float | r | 获取此图像的不透明度。 |
| interrupt_monitor | InterruptMonitor | r/w | 获取或设置中断监视器。 |
| is_cached | bool | r | 获取指示图像数据当前是否已缓存的值。 |
| is_raw_data_available | bool | r | 获取指示是否支持原始数据加载的值。 |
| metadata | ImageMetadata | r | 获取或设置来自帧的 XMP 数据。 |
| options | WebPOptions | r | 检索或修改与指定属性关联的选项,以实现 对行为和设置的精细定制。利用此属性 无缝访问和操作可配置参数,促进多样化的 在您的应用功能中的控制和优化。 |
| page_count | int | r | 检索指定文档的总页数,以便 高效导航和管理多页内容。整合此 功能以提升用户体验,实现对 完整文档结构的无缝访问。 |
| pages | Image[] | r | 访问图像中的 WebP 块,允许对底层块结构进行详细检查或 操作。利用此属性分析 或修改 WebP 图像数据中的单个块,以促进高级的 在您的应用程序中的图像处理技术。 |
| palette | IColorPalette | r/w | 获取或设置颜色调色板。当像素直接表示时,不使用颜色调色板。 |
| premultiply_components | bool | r/w | 获取或设置一个值,指示图像组件是否必须进行预乘。 |
| raw_custom_color_converter | IColorConverter | r/w | 获取或设置自定义颜色转换器 |
| raw_data_format | PixelDataFormat | r | 获取原始数据格式。 |
| raw_data_settings | RawDataSettings | r | 获取当前原始数据设置。注意,使用这些设置时,数据将在不进行转换的情况下加载。 |
| raw_fallback_index | int | r/w | 获取或设置当调色板索引超出范围时使用的回退索引 |
| raw_indexed_color_converter | IIndexedColorConverter | r/w | 获取或设置索引颜色转换器 |
| raw_line_size | int | r | 获取以字节为单位的原始行大小。 |
| size | Size | r | 获取对象大小。 |
| transparent_color | Color | r/w | 获取图像的透明颜色。 |
| update_xmp_data | bool | r/w | 获取或设置一个值,指示是否更新 XMP 元数据。 |
| use_palette | bool | r | 获取一个值,指示是否使用图像调色板。 |
| use_raw_data | bool | r/w | 获取或设置一个值,指示在可用原始数据加载时是否使用原始数据加载。 |
| vertical_resolution | float | r/w | 获取或设置此 RasterImage 的垂直分辨率(每英寸像素数)。 |
| width | int | r | 获取图像宽度。 |
| xmp_data | XmpPacketWrapper | r/w | 获取或设置 Xmp 数据。 |
Methods
Constructor: WebPImage(path)
WebPImage(path)
实例化一个全新的 WebPImage 类,初始化
来自提供的文件源。利用此构造函数可无缝地直接从文件创建 WebP
图像对象,简化在应用程序中加载和
操作 WebP 图像数据的过程。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 路径 | string | WebP 图像文件的路径 |
See also:
Example # 1: This example shows how to load a WebP image from a file and save it to PNG.
Constructor: WebPImage(path, load_options)
WebPImage(path, load_options)
使用文件和
指定的加载选项创建一个新的 WebPImage 类实例,以便灵活处理 WebP 图像数据。利用
此构造函数可无缝地从文件初始化 WebP 图像对象,同时
根据应用程序的需求自定义加载参数。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 路径 | string | WebP 图像文件的路径 |
| load_options | LoadOptions | 加载选项。 |
Constructor: WebPImage(raster_image)
WebPImage(raster_image)
实例化一个新的 WebPImage 类实例,初始化
来自提供的 rasterImage 对象。此构造函数允许无缝地
将光栅图像转换为 WebP 格式,从而在应用程序中实现高效的图像数据处理和
操作。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| raster_image | RasterImage | 光栅图像。 |
See also:
Example # 1: This example shows how to create a WebP image from another raster image.
Constructor: WebPImage(raster_image, load_options)
WebPImage(raster_image, load_options)
使用 rasterImage 对象和
指定的加载选项创建一个新的 WebPImage 类实例,以实现灵活的图像数据处理。利用此
构造函数可无缝地从光栅图像初始化 WebP 图像对象,同时
根据应用程序的需求自定义加载参数。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| raster_image | RasterImage | 光栅图像。 |
| load_options | LoadOptions | 加载选项。 |
Constructor: WebPImage(stream)
WebPImage(stream)
实例化一个新的 WebPImage 类的实例,已初始化
来自提供的流源。利用此构造函数可无缝地直接从流创建 WebP
图像对象,实现对 WebP 图像数据的高效处理和操作
在您的应用程序中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | WebP 图像流。 |
See also:
Example # 1: This example shows how to load a WebP image from a file stream and save it to…
Constructor: WebPImage(stream, load_options)
WebPImage(stream, load_options)
从流中创建一个新的 WebPImage 类的实例,
并结合指定的加载选项和内存管理设置。此构造函数在从流加载 WebP 图像时提供灵活性,同时
高效管理内存资源,确保最佳性能和资源
在您的应用程序中的利用率。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | WebP 图像流。 |
| load_options | LoadOptions | 加载选项。 |
Constructor: WebPImage(width, height, options)
WebPImage(width, height, options)
实例化一个新的 WebPImage 类的实例,使用空的
指定宽度和高度的图像。此构造函数允许创建空白 WebP 图像,为后续的图像
操作和内容生成提供基础。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| width | int | 图像宽度 |
| height | int | 图像高度。 |
| options | WebPOptions | 选项。 |
See also:
Example # 1: This example shows how to create a WebP image with the specified options from…
Constructor: WebPImage(width, height, options, load_options)
WebPImage(width, height, options, load_options)
创建一个新的 WebPImage 类的实例,使用空图像并指定
加载选项。此构造函数允许使用可定制的加载参数,为图像创建和
在您的应用程序中的操作提供灵活性。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| width | int | 图像宽度 |
| height | int | 图像高度。 |
| options | WebPOptions | 选项。 |
| load_options | LoadOptions | 加载选项。 |
Property: has_alpha
获取图像是否包含 alpha 通道,以指示
透明度信息的存在。利用此属性确定图像是否
包含透明度,从而实现对 alpha 相关操作的适当处理和处理,在您的应用程序中。
See also:
Example # 1: The following example loads a WEBP image and prints information about raw dat…
Method: add_block(block)
add_block(block)
将新的 WebP 块合并到图像中,丰富其内容并
促进高级图像操作。整合此方法以动态
提升您应用中 WebP 图像数据的结构和复杂性,
实现对图像渲染的精确控制和优化。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| block | IFrame | 要添加的 WebP 块。 |
Method: add_page(page)
add_page(page)
向图像追加新页面,扩展其内容并容纳额外的
视觉元素。整合此方法以促进动态页面管理
在您的应用程序中,实现多页文档或图像的无缝创建和增强。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| page | RasterImage | 要添加的页面。 |
Method: adjust_brightness(brightness)
adjust_brightness(brightness)
实现图像的 brightness(亮度)调整,允许
整体亮度水平的修改。将此方法整合到您的图像
处理工作流中,以提升可见性并改善图像的视觉质量
在您的应用程序中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 亮度 | int | 亮度值。 |
Method: adjust_contrast(contrast)
adjust_contrast(contrast)
增强 Image 的对比度,放大
明暗区域之间的差异。将此方法整合到您的图像
处理工作流中,以提升视觉清晰度和整体图像质量
在您的应用程序中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 对比度 | float | 对比度值(范围为 [-100; 100]) |
Method: adjust_gamma(gamma)
adjust_gamma(gamma)
对图像应用伽马校正,调整像素强度以实现
所需的亮度和色彩平衡。将此方法整合到您的图像
处理工作流中,以提升视觉质量并提高后续分析或显示任务的准确性
在您的应用程序中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 伽马 | float | 红、绿、蓝通道的伽马系数 |
Method: adjust_gamma(gamma_red, gamma_green, gamma_blue)
adjust_gamma(gamma_red, gamma_green, gamma_blue)
使用红、
绿和蓝通道的单独系数对图像进行伽马校正,以实现对色彩平衡和
对比度的精细调节。将此方法整合到您的图像处理管线中,以实现
对颜色渲染的精确控制,并在您的
应用程序中提升视觉保真度。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| gamma_red | float | 红色通道的伽马系数 |
| gamma_green | float | 绿色通道的伽马系数 |
| gamma_blue | float | 蓝色通道系数的 Gamma |
Method: analyze_percentage_digital_signature(password)
analyze_percentage_digital_signature(password)
计算提取数据与原始密码之间的相似度百分比。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 密码 | string | 用于提取嵌入数据的密码。 |
Returns
| Type | Description |
|---|---|
| int | 百分比相似度值。 |
Method: binarize_bradley(brightness_difference)
binarize_bradley(brightness_difference)
使用 Bradley 的自适应阈值算法和积分图阈值进行图像二值化
Parameters:
| 参数 | Type | Description |
|---|---|---|
| brightness_difference | float | 像素与以该像素为中心的 s x s 像素窗口的平均值之间的亮度差 。 |
Method: binarize_bradley(brightness_difference, window_size)
binarize_bradley(brightness_difference, window_size)
使用 Bradley 自适应阈值算法对图像进行二值化,
结合积分图阈值。此方法动态计算局部阈值,基于图像邻域,提高对不同
光照条件的适应性,并确保后续处理任务的稳健分割
在您的应用程序中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| brightness_difference | float | 像素与以该像素为中心的 s x s 像素窗口的平均值之间的亮度差 。 |
| window_size | int | 以该像素为中心的 s x s 像素窗口的大小 |
Method: binarize_fixed(threshold)
binarize_fixed(threshold)
使用预定义阈值对图像进行二值化,将其转换为
二进制图像,像素根据相对于阈值的强度被分类为前景或背景
。将此方法整合到
您的图像处理工作流中,以促进分割和特征提取
任务,提高后续分析的准确性和效率
在您的应用程序中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 阈值 | System.Byte | 阈值。如果像素的对应灰度值大于阈值,则赋值为 255,否则为 0。 |
Method: blend(origin, overlay, overlay_alpha)
blend(origin, overlay, overlay_alpha)
将此图像实例与 overlay 图像混合。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| origin | Point | 背景图像混合的原点。 |
| overlay | RasterImage | 覆盖图像。 |
| overlay_alpha | System.Byte | 覆盖的 alpha。 |
Method: blend(origin, overlay, overlay_area, overlay_alpha)
blend(origin, overlay, overlay_area, overlay_alpha)
将此图像实例与 overlay 图像混合。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| origin | Point | 背景图像混合的原点。 |
| overlay | RasterImage | 覆盖图像。 |
| overlay_area | Rectangle | 覆盖区域。 |
| overlay_alpha | System.Byte | 覆盖的 alpha。 |
Method: can_load(file_path) [static]
can_load(file_path)
确定是否可以从指定的文件路径加载图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 文件路径。 |
Returns
| Type | Description |
|---|---|
| bool |
Method: can_load(file_path, load_options) [static]
can_load(file_path, load_options)
确定是否可以从指定的文件路径加载图像,并可选地使用指定的打开选项。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 文件路径。 |
| load_options | LoadOptions | 加载选项。 |
Returns
| Type | Description |
|---|---|
| bool |
Method: can_load(stream) [static]
can_load(stream)
确定是否可以从指定的流加载图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 要加载的流。 |
Returns
| Type | Description |
|---|---|
| bool |
Method: can_load(stream, load_options) [static]
can_load(stream, load_options)
确定是否可以从指定的流加载图像,并可选地使用指定的 loadOptions。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 要加载的流。 |
| load_options | LoadOptions | 加载选项。 |
Returns
| Type | Description |
|---|---|
| bool |
Method: can_load_stream(stream) [static]
can_load_stream(stream)
确定是否可以从指定的流加载图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 要加载的流。 |
Returns
| Type | Description |
|---|---|
| bool |
Method: can_load_stream_with_options(stream, load_options) [static]
can_load_stream_with_options(stream, load_options)
确定是否可以从指定的流加载图像,并可选地使用指定的 loadOptions。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 要加载的流。 |
| load_options | LoadOptions | 加载选项。 |
Returns
| Type | Description |
|---|---|
| bool |
Method: can_load_with_options(file_path, load_options) [static]
can_load_with_options(file_path, load_options)
确定是否可以从指定的文件路径加载图像,并可选地使用指定的打开选项。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 文件路径。 |
| load_options | LoadOptions | 加载选项。 |
Returns
| Type | Description |
|---|---|
| bool |
Method: can_save(options)
can_save(options)
确定是否可以将图像保存为由传入的保存选项表示的指定文件格式。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| options | ImageOptionsBase | 要使用的保存选项。 |
Returns
| Type | Description |
|---|---|
| bool |
Method: create(files) [static]
create(files)
创建包含指定文件的多页图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 文件 | string[] | 文件。 |
Returns
| Type | Description |
|---|---|
| Image | 多页图像 |
Method: create(files, throw_exception_on_load_error) [static]
create(files, throw_exception_on_load_error)
创建包含指定文件的多页图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 文件 | string[] | 文件。 |
| throw_exception_on_load_error | bool | 如果设置为 |
Returns
| Type | Description |
|---|---|
| Image | 多页图像 |
Method: create(image_options, width, height) [static]
create(image_options, width, height)
使用指定的创建选项创建新图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| image_options | ImageOptionsBase | 图像选项。 |
| width | int | 宽度。 |
| height | int | 高度。 |
Returns
| Type | Description |
|---|---|
| Image | 新创建的图像。 |
Method: create(image_options, width, height, pixels) [static]
create(image_options, width, height, pixels)
创建一个来自提供的像素数组的 RasterImage 实例。
验证指定的宽度和高度是否与像素数据的维度匹配。
仅当库处于授权模式时才能使用此方法。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| image_options | ImageOptionsBase | 用于创建 RasterImage 的选项。 |
| width | int | RasterImage 的宽度。 |
| height | int | RasterImage 的高度。 |
| 像素 | int[] | 用于填充图像的像素值数组。 |
Returns
| Type | Description |
|---|---|
| Image | 使用提供的像素数据填充的 RasterImage。 |
Method: create(images) [static]
create(images)
使用指定的图像作为页面创建新图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| images | Image[] | 图像。 |
Returns
| Type | Description |
|---|---|
| Image | Image 作为 IMultipageImage |
Method: create(images, dispose_images) [static]
create(images, dispose_images)
创建一个新图像,将指定的图像作为页面。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| images | Image[] | 图像。 |
| dispose_images | bool | 如果设置为 |
Returns
| Type | Description |
|---|---|
| Image | Image 作为 IMultipageImage |
Method: create(multipage_create_options) [static]
create(multipage_create_options)
创建指定的多页创建选项。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| multipage_create_options | MultipageCreateOptions | 多页创建选项。 |
Returns
| Type | Description |
|---|---|
| Image | 多页图像 |
Method: create_from_file_with_options(path, load_options) [static]
create_from_file_with_options(path, load_options)
从文件初始化一个新的 WebPImage 类的实例。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 路径 | string | WebP 图像文件的路径 |
| load_options | LoadOptions | 加载选项。 |
Returns
| Type | Description |
|---|---|
| WebPImage |
Method: create_from_files(files) [static]
create_from_files(files)
创建包含指定文件的多页图像,将其作为延迟加载页面。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 文件 | string[] | 文件。 |
Returns
| Type | Description |
|---|---|
| Image | 多页图像 |
Method: create_from_files(files, throw_exception_on_load_error) [static]
create_from_files(files, throw_exception_on_load_error)
创建包含指定文件的多页图像,将其作为延迟加载页面。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 文件 | string[] | 文件。 |
| throw_exception_on_load_error | bool | 如果设置为 |
Returns
| Type | Description |
|---|---|
| Image | 多页图像 |
Method: create_from_image(raster_image) [static]
create_from_image(raster_image)
从 rasterImage 初始化一个新的 WebPImage 类的实例。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| raster_image | RasterImage | 光栅图像。 |
Returns
| Type | Description |
|---|---|
| WebPImage |
Method: create_from_image_with_options(raster_image, load_options) [static]
create_from_image_with_options(raster_image, load_options)
从 rasterImage 初始化一个新的 WebPImage 类的实例。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| raster_image | RasterImage | 光栅图像。 |
| load_options | LoadOptions | 加载选项。 |
Returns
| Type | Description |
|---|---|
| WebPImage |
Method: create_from_images(images) [static]
create_from_images(images)
使用指定的图像作为页面创建新图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| images | Image[] | 图像。 |
Returns
| Type | Description |
|---|---|
| Image | Image 作为 IMultipageImage |
Method: create_from_images(images, dispose_images) [static]
create_from_images(images, dispose_images)
创建一个新图像,将指定的图像作为页面。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| images | Image[] | 图像。 |
| dispose_images | bool | 如果设置为 |
Returns
| Type | Description |
|---|---|
| Image | Image 作为 IMultipageImage |
Method: create_from_stream(stream) [static]
create_from_stream(stream)
初始化一个新的 WebPImage 类的实例
来自流。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | WebP 图像流。 |
Returns
| Type | Description |
|---|---|
| WebPImage |
Method: create_from_stream_with_options(stream, load_options) [static]
create_from_stream_with_options(stream, load_options)
从流初始化一个新的 WebPImage 类的实例。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | WebP 图像流。 |
| load_options | LoadOptions | 加载选项。 |
Returns
| Type | Description |
|---|---|
| WebPImage |
Method: crop(left_shift, right_shift, top_shift, bottom_shift)
crop(left_shift, right_shift, top_shift, bottom_shift)
通过左右上下平移裁剪图像,有效地
在图像中选择感兴趣的区域。利用此方法
动态提取图像所需部分,同时调整其构图
和焦点,以满足您的应用需求。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| left_shift | int | 左移。 |
| right_shift | int | 右移。 |
| top_shift | int | 上移。 |
| bottom_shift | int | 下移。 |
Method: crop(rectangle)
crop(rectangle)
使用指定的矩形区域裁剪图像,去除不需要的部分
同时保留所需内容。将此方法整合到您的图像
处理工作流中,以精确提取并聚焦图像中感兴趣的特定区域
提升清晰度和构图,适用于各种应用。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 矩形。 |
Method: dither(dithering_method, bits_count)
dither(dithering_method, bits_count)
对当前图像执行抖动处理。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| dithering_method | DitheringMethod | 抖动方法。 |
| bits_count | int | 用于抖动的最终位计数。 |
Method: dither(dithering_method, bits_count, custom_palette)
dither(dithering_method, bits_count, custom_palette)
对当前图像执行抖动以降低颜色条纹并提升视觉
质量。将此方法集成到您的图像处理工作流中,以实现
更平滑的颜色过渡,并改善图像在您的应用程序中的整体外观。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| dithering_method | DitheringMethod | 抖动方法。 |
| bits_count | int | 用于抖动的最终位计数。 |
| custom_palette | IColorPalette | 用于抖动的自定义调色板。 |
Method: embed_digital_signature(password)
embed_digital_signature(password)
根据提供的密码将数字签名嵌入图像的每一页。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 密码 | string | 用于生成数字签名数据的密码 |
Method: filter(rectangle, options)
filter(rectangle, options)
在指定矩形区域内过滤内容,应用指定的图像
处理滤镜以增强或修改所选区域。将此方法
集成到您的图像操作工作流中,以实现针对性的增强或
转换,在您的应用程序中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 矩形。 |
| options | FilterOptionsBase | 选项。 |
Method: get_argb_32_pixel(x, y)
get_argb_32_pixel(x, y)
获取图像的 32 位 ARGB 像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| x | int | 像素的 x 位置。 |
| y | int | 像素的 y 位置。 |
Returns
| Type | Description |
|---|---|
| int | 指定位置的 32 位 ARGB 像素。 |
Method: get_default_argb_32_pixels(rectangle)
get_default_argb_32_pixels(rectangle)
获取默认的 32 位 ARGB 像素数组。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 用于获取像素的矩形。 |
Returns
| Type | Description |
|---|---|
| int[] | 默认像素数组。 |
Method: get_default_options(args)
get_default_options(args)
获取默认选项。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| args | System.Object | 参数。 |
Returns
| Type | Description |
|---|---|
| ImageOptionsBase | 默认选项 |
Method: get_default_pixels(rectangle, partial_pixel_loader)
get_default_pixels(rectangle, partial_pixel_loader)
使用部分像素加载器获取默认像素数组。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 用于获取像素的矩形。 |
| partial_pixel_loader | IPartialArgb32PixelLoader | 部分像素加载器。 |
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)
使用部分像素加载器获取默认原始数据数组。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 用于获取像素的矩形。 |
| partial_raw_data_loader | IPartialRawDataLoader | 部分原始数据加载器。 |
| raw_data_settings | RawDataSettings | 原始数据设置。 |
Method: get_default_raw_data(rectangle, raw_data_settings)
get_default_raw_data(rectangle, raw_data_settings)
获取默认原始数据数组。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 用于获取原始数据的矩形。 |
| raw_data_settings | RawDataSettings | 原始数据设置。 |
Returns
| Type | Description |
|---|---|
| System.Byte | 默认原始数据数组。 |
Method: get_file_format(file_path) [static]
get_file_format(file_path)
获取文件格式。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 文件路径。 |
Returns
| Type | Description |
|---|---|
| FileFormat | 确定的文件格式。 |
Method: get_file_format(stream) [static]
get_file_format(stream)
获取文件格式。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 该流。 |
Returns
| Type | Description |
|---|---|
| FileFormat | 确定的文件格式。 |
Method: get_file_format_of_stream(stream) [static]
get_file_format_of_stream(stream)
获取文件格式。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 该流。 |
Returns
| Type | Description |
|---|---|
| FileFormat | 确定的文件格式。 |
Method: get_fitting_rectangle(rectangle, pixels, width, height) [static]
get_fitting_rectangle(rectangle, pixels, width, height)
获取适合当前图像的矩形。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 用于获取合适矩形的矩形。 |
| 像素 | int[] | 32 位 ARGB 像素。 |
| width | int | 对象宽度。 |
| height | int | 对象高度。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 适配矩形,若未找到适配矩形则抛出异常。 |
Method: get_fitting_rectangle(rectangle, width, height) [static]
get_fitting_rectangle(rectangle, width, height)
获取适合当前图像的矩形。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 用于获取合适矩形的矩形。 |
| width | int | 对象宽度。 |
| height | int | 对象高度。 |
Returns
| Type | Description |
|---|---|
| Rectangle | 适配矩形,若未找到适配矩形则抛出异常。 |
Method: get_modify_date(use_default)
get_modify_date(use_default)
获取资源图像最后修改的日期和时间。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| use_default | bool | 如果设置为 |
Returns
| Type | Description |
|---|---|
| System.DateTime | 资源图像上次修改的日期和时间。 |
Method: get_original_options()
get_original_options()
根据原始文件设置获取选项。
这有助于保持原始图像的位深度和其他参数不变。
例如,如果我们加载一个每像素 1 位的黑白 PNG 图像,然后使用
DataStreamSupporter.save(file_path) 方法保存,它将生成每像素 8 位的输出 PNG 图像。
为避免这种情况并以每像素 1 位保存 PNG 图像,请使用此方法获取相应的保存选项,并将其
作为第二个参数传递给 Image.save(file_path, options) 方法。
Returns
| Type | Description |
|---|---|
| ImageOptionsBase | 基于原始文件设置的选项。 |
Method: get_pixel(x, y)
get_pixel(x, y)
获取图像像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| x | int | 像素的 x 位置。 |
| y | int | 像素的 y 位置。 |
Returns
| Type | Description |
|---|---|
| Color | 指定位置的像素颜色。 |
Method: get_proportional_height(width, height, new_width) [static]
get_proportional_height(width, height, new_width)
获取比例高度。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| width | int | 宽度。 |
| height | int | 高度。 |
| new_width | int | 新的宽度。 |
Returns
| Type | Description |
|---|---|
| int | 比例高度。 |
Method: get_proportional_width(width, height, new_height) [static]
get_proportional_width(width, height, new_height)
获取比例宽度。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| width | int | 宽度。 |
| height | int | 高度。 |
| new_height | int | 新的高度。 |
Returns
| Type | Description |
|---|---|
| int | 比例宽度。 |
Method: get_serialized_stream(image_options, clipping_rectangle, page_number)
get_serialized_stream(image_options, clipping_rectangle, page_number)
转换为 aps。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| image_options | ImageOptionsBase | 图像选项。 |
| clipping_rectangle | Rectangle | 裁剪矩形。 |
| page_number | int[] | 页码。 |
Returns
| Type | Description |
|---|---|
| _io.BufferedRandom | 序列化流 |
Method: get_skew_angle()
get_skew_angle()
获取倾斜角度。
此方法适用于扫描的文本文件,用于在扫描时确定倾斜角度。
Returns
| Type | Description |
|---|---|
| float | 倾斜角度(单位:度)。 |
Method: insert_block(index, block)
insert_block(index, block)
在图像中指定索引处插入新的 WebP 块,以实现对块序列的精确
控制。将此方法集成以无缝地将
额外的 WebP 块加入图像数据结构,促进高级图像
处理和优化在您的应用程序中的实现。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| index | int | 零基索引元素,block 将在此处 插入。 |
| block | IFrame | 要添加的 WebP 块。 |
Method: is_digital_signed(password, percentage_threshold)
is_digital_signed(password, percentage_threshold)
使用提供的密码和阈值执行快速检查,以确定图像是否已数字签名。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 密码 | string | 用于检查签名的密码。 |
| percentage_threshold | int | 阈值(百分比)[0-100] 用于确定图像是否被视为已签名。 如果未指定,将使用默认阈值( |
Returns
| Type | Description |
|---|---|
| bool | 如果图像已签名则为 true,否则为 false。 |
Method: load(file_path) [static]
load(file_path)
从指定的文件路径或 URL 加载新图像。
如果 filePath 是文件路径,方法仅打开该文件。
如果 filePath 是 URL,方法会下载文件,将其存为临时文件,然后打开它。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 加载图像的文件路径或 URL。 |
Returns
| Type | Description |
|---|---|
| Image | 已加载的图像。 |
Method: load(file_path, load_options) [static]
load(file_path, load_options)
从指定的文件路径或 URL 加载新图像。
如果 filePath 是文件路径,方法仅打开该文件。
如果 filePath 是 URL,方法会下载文件,将其存为临时文件,然后打开它。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 加载图像的文件路径或 URL。 |
| load_options | LoadOptions | 加载选项。 |
Returns
| Type | Description |
|---|---|
| Image | 已加载的图像。 |
Method: load(stream) [static]
load(stream)
从指定的流加载新图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 加载图像的流。 |
Returns
| Type | Description |
|---|---|
| Image | 已加载的图像。 |
Method: load(stream, load_options) [static]
load(stream, load_options)
从流中加载数据。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | WebP 图像流。 |
| load_options | LoadOptions | 加载选项 |
Returns
| Type | Description |
|---|---|
| Image |
Method: load_argb_32_pixels(rectangle)
load_argb_32_pixels(rectangle)
加载 32 位 ARGB 像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 加载像素的矩形。 |
Returns
| Type | Description |
|---|---|
| int[] | 已加载的 32 位 ARGB 像素数组。 |
Method: load_argb_64_pixels(rectangle)
load_argb_64_pixels(rectangle)
加载 64 位 ARGB 像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 加载像素的矩形。 |
Returns
| Type | Description |
|---|---|
| int[] | 已加载的 64 位 ARGB 像素数组。 |
Method: load_cmyk_32_pixels(rectangle)
load_cmyk_32_pixels(rectangle)
加载 CMYK 格式的像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 加载像素的矩形。 |
Returns
| Type | Description |
|---|---|
| int[] | 已加载的 CMYK 像素以 32 位整数值呈现。 |
Method: load_cmyk_pixels(rectangle)
load_cmyk_pixels(rectangle)
加载 CMYK 格式的像素。
此方法已弃用。请使用更有效的 RasterImage.load_cmyk_32_pixels(rectangle) 方法。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 加载像素的矩形。 |
Returns
| Type | Description |
|---|---|
| CmykColor[] | 已加载的 CMYK 像素数组。 |
Method: load_partial_argb_32_pixels(rectangle, partial_pixel_loader)
load_partial_argb_32_pixels(rectangle, partial_pixel_loader)
部分加载 32 位 ARGB 像素(按块)。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 加载像素的矩形。 |
| partial_pixel_loader | IPartialArgb32PixelLoader | 部分像素加载器。 |
Method: load_partial_argb_64_pixels(rectangle, partial_pixel_loader)
load_partial_argb_64_pixels(rectangle, partial_pixel_loader)
按包部分加载 64 位 ARGB 像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 所需的矩形。 |
| partial_pixel_loader | IPartialArgb64PixelLoader | 64 位 ARGB 像素加载器。 |
Method: load_partial_pixels(desired_rectangle, pixel_loader)
load_partial_pixels(desired_rectangle, pixel_loader)
按包部分加载像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| desired_rectangle | Rectangle | 所需的矩形。 |
| pixel_loader | IPartialPixelLoader | 像素加载器。 |
Method: load_pixels(rectangle)
load_pixels(rectangle)
加载像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 加载像素的矩形。 |
Returns
| Type | Description |
|---|---|
| Color[] | 已加载的像素数组。 |
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)
加载原始数据。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 用于加载原始数据的矩形。 |
| dest_image_bounds | Rectangle | 目标图像边界。 |
| raw_data_settings | RawDataSettings | 用于已加载数据的原始数据设置。注意,如果数据不是指定的格式,则会执行数据转换。 |
| raw_data_loader | IPartialRawDataLoader | 原始数据加载器。 |
Method: load_raw_data(rectangle, raw_data_settings, raw_data_loader)
load_raw_data(rectangle, raw_data_settings, raw_data_loader)
加载原始数据。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 用于加载原始数据的矩形。 |
| raw_data_settings | RawDataSettings | 用于已加载数据的原始数据设置。注意,如果数据不是指定的格式,则会执行数据转换。 |
| raw_data_loader | IPartialRawDataLoader | 原始数据加载器。 |
Method: load_stream(stream) [static]
load_stream(stream)
从指定的流加载新图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 加载图像的流。 |
Returns
| Type | Description |
|---|---|
| Image | 已加载的图像。 |
Method: load_stream_with_options(stream, load_options) [static]
load_stream_with_options(stream, load_options)
从指定的流加载新图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 加载图像的流。 |
| load_options | LoadOptions | 加载选项。 |
Returns
| Type | Description |
|---|---|
| Image | 已加载的图像。 |
Method: load_with_options(file_path, load_options) [static]
load_with_options(file_path, load_options)
从指定的文件路径或 URL 加载新图像。
如果 filePath 是文件路径,方法仅打开该文件。
如果 filePath 是 URL,方法会下载文件,将其存为临时文件,然后打开它。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 加载图像的文件路径或 URL。 |
| load_options | LoadOptions | 加载选项。 |
Returns
| Type | Description |
|---|---|
| Image | 已加载的图像。 |
Method: normalize_angle(resize_proportionally, background_color)
normalize_angle(resize_proportionally, background_color)
归一化角度。
此方法适用于扫描的文本文档,以消除倾斜扫描。
此方法使用 RasterImage.get_skew_angle() 和 RasterCachedMultipageImage.rotate(angle, resize_proportionally, background_color) 方法。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| resize_proportionally | bool | 如果设置为 |
| background_color | Color | 背景颜色。 |
Method: read_argb_32_scan_line(scan_line_index)
read_argb_32_scan_line(scan_line_index)
按指定的扫描线索引读取整条扫描线。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| scan_line_index | int | 扫描线的零基索引。 |
Returns
| Type | Description |
|---|---|
| int[] | 扫描线 32 位 ARGB 颜色值数组。 |
Method: read_scan_line(scan_line_index)
read_scan_line(scan_line_index)
按指定的扫描线索引读取整条扫描线。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| scan_line_index | int | 扫描线的零基索引。 |
Returns
| Type | Description |
|---|---|
| Color[] | 扫描线像素颜色值数组。 |
Method: remove_block(block)
remove_block(block)
从图像中移除指定的 WebP 块,便于高效管理
图像数据结构。使用此方法通过消除不必要的块或组件来简化图像处理
工作流,在您的应用程序中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| block | IFrame | 要删除的块。 |
Method: replace_argb(old_color_argb, old_color_diff, new_color_argb)
replace_argb(old_color_argb, old_color_diff, new_color_argb)
在允许的差异范围内将一种颜色替换为另一种颜色,并保留原始 alpha 值以保持平滑边缘。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| old_color_argb | int | 要替换的旧颜色 ARGB 值。 |
| old_color_diff | System.Byte | 允许的旧颜色差异,以便能够扩大替换颜色的色调。 |
| new_color_argb | int | 用于替换旧颜色的新颜色 ARGB 值。 |
Method: replace_color(old_color, old_color_diff, new_color)
replace_color(old_color, old_color_diff, new_color)
在允许的差异范围内将一种颜色替换为另一种颜色,并保留原始 alpha 值以保持平滑边缘。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| old_color | Color | |
| old_color_diff | System.Byte | 允许的旧颜色差异,以便能够扩大替换颜色的色调。 |
| 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)
在允许的差异范围内将一种颜色替换为另一种颜色,并保留原始 alpha 值以保持平滑边缘。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| old_color_argb | int | 要替换的旧颜色 ARGB 值。 |
| old_color_diff | System.Byte | 允许的旧颜色差异,以便能够扩大替换颜色的色调。 |
| new_color_argb | int | 用于替换旧颜色的新颜色 ARGB 值。 |
Method: replace_non_transparent_colors(new_color)
replace_non_transparent_colors(new_color)
将所有非透明颜色替换为新颜色,并保留原始 alpha 值以保持平滑边缘。
注意:如果在没有透明度的图像上使用,它将把所有颜色替换为单一颜色。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_color | Color |
Method: replace_non_transparent_colors(new_color_argb)
replace_non_transparent_colors(new_color_argb)
将所有非透明颜色替换为新颜色,并保留原始 alpha 值以保持平滑边缘。
注意:如果在没有透明度的图像上使用,它将把所有颜色替换为单一颜色。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_color_argb | int | 用于替换非透明颜色的新颜色 ARGB 值。 |
Method: resize(new_width, new_height)
resize(new_width, new_height)
调整图像大小。使用默认的 ResizeType.NEAREST_NEIGHBOUR_RESAMPLE。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_width | int | 新的宽度。 |
| new_height | int | 新的高度。 |
Method: resize(new_width, new_height, resize_type)
resize(new_width, new_height, resize_type)
调整图像大小,改变其尺寸同时保持纵横比。
将此方法集成到您的图像处理工作流中,以动态缩放
图像以满足应用程序中各种显示或存储需求。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_width | int | 新的宽度。 |
| new_height | int | 新的高度。 |
| resize_type | ResizeType | 调整大小类型。 |
Method: resize(new_width, new_height, settings)
resize(new_width, new_height, settings)
根据指定设置调整图像大小,实现对
尺寸、纵横比和缩放行为的精确控制。将此方法集成到您的
图像处理工作流中,以实现符合您应用程序特定需求的定制化调整操作。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_width | int | 新的宽度。 |
| new_height | int | 新的高度。 |
| settings | ImageResizeSettings | 调整大小设置。 |
Method: resize_by_settings(new_width, new_height, settings)
resize_by_settings(new_width, new_height, settings)
调整图像大小。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_width | int | 新的宽度。 |
| new_height | int | 新的高度。 |
| settings | ImageResizeSettings | 调整大小设置。 |
Method: resize_by_type(new_width, new_height, resize_type)
resize_by_type(new_width, new_height, resize_type)
调整图像大小。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_width | int | 新的宽度。 |
| new_height | int | 新的高度。 |
| resize_type | ResizeType | 调整大小类型。 |
Method: resize_height_proportionally(new_height)
resize_height_proportionally(new_height)
按比例调整高度。默认使用 ResizeType.NEAREST_NEIGHBOUR_RESAMPLE。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_height | int | 新的高度。 |
Method: resize_height_proportionally(new_height, resize_type)
resize_height_proportionally(new_height, resize_type)
按比例调整图像高度,同时保持其纵横比
以实现一致的缩放。将此方法集成到您的图像处理工作流中
动态地以统一比例调整图像大小,确保在您的应用程序中获得最佳显示或
存储效果。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_height | int | 新的高度。 |
| resize_type | ResizeType | 调整大小的类型。 |
Method: resize_height_proportionally(new_height, settings)
resize_height_proportionally(new_height, settings)
按比例调整高度。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_height | int | 新的高度。 |
| settings | ImageResizeSettings | 图像调整大小设置。 |
Method: resize_height_proportionally_settings(new_height, settings)
resize_height_proportionally_settings(new_height, settings)
按比例调整高度。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_height | int | 新的高度。 |
| settings | ImageResizeSettings | 图像调整大小设置。 |
Method: resize_width_proportionally(new_width)
resize_width_proportionally(new_width)
按比例调整宽度。默认使用 ResizeType.NEAREST_NEIGHBOUR_RESAMPLE。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_width | int | 新的宽度。 |
Method: resize_width_proportionally(new_width, resize_type)
resize_width_proportionally(new_width, resize_type)
按比例调整图像宽度,同时保持其纵横比。
将此方法集成到您的图像处理工作流中,以动态缩放
图像并保持一致的比例,确保在您的应用程序中获得最佳显示或存储。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_width | int | 新的宽度。 |
| resize_type | ResizeType | 调整大小的类型。 |
Method: resize_width_proportionally(new_width, settings)
resize_width_proportionally(new_width, settings)
按比例调整宽度。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_width | int | 新的宽度。 |
| settings | ImageResizeSettings | 图像调整大小设置。 |
Method: resize_width_proportionally_settings(new_width, settings)
resize_width_proportionally_settings(new_width, settings)
按比例调整宽度。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| new_width | int | 新的宽度。 |
| settings | ImageResizeSettings | 图像调整大小设置。 |
Method: rotate(angle)
rotate(angle)
围绕中心旋转图像。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 角度 | float | 旋转角度(以度为单位)。正值将顺时针旋转。 |
Method: rotate(angle, resize_proportionally, background_color)
rotate(angle, resize_proportionally, background_color)
围绕中心按指定角度旋转图像,同时按比例
调整大小并应用指定的背景颜色参数。将此
方法纳入您的图像处理工作流,以实现具有可自定义背景颜色的精确变换,确保在您的
应用程序中获得最佳视觉呈现。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 角度 | float | 旋转角度(以度为单位)。正值将顺时针旋转。 |
| resize_proportionally | bool | 如果设置为 根据旋转矩形(角点)的投影在其他 情况下,尺寸保持不变,仅 internal 图像内容被旋转。 |
| background_color | Color | 背景颜色。 |
Method: rotate_flip(rotate_flip_type)
rotate_flip(rotate_flip_type)
将旋转、翻转或两者操作仅应用于图像中的活动帧
。将此方法集成到您的图像处理工作流中,以
实现对单帧的精确操作,提升灵活性和
对帧转换的控制,在您的应用程序中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rotate_flip_type | RotateFlipType | 旋转翻转类型。 |
Method: rotate_flip_all(rotate_flip)
rotate_flip_all(rotate_flip)
旋转并翻转全部。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rotate_flip | RotateFlipType | 旋转翻转。 |
Method: save(file_path)
save(file_path)
将图像保存到指定的文件位置。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 保存图像的文件路径。 |
Method: save(file_path, options)
save(file_path, options)
根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 文件路径。 |
| options | ImageOptionsBase | 选项。 |
Method: save(file_path, options, bounds_rectangle)
save(file_path, options, bounds_rectangle)
根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 文件路径。 |
| options | ImageOptionsBase | 选项。 |
| bounds_rectangle | Rectangle | 目标图像边界矩形。将空矩形设置为使用源边界。 |
Method: save(file_path, over_write)
save(file_path, over_write)
将对象的数据保存到指定的文件位置。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 保存对象数据的文件路径。 |
| over_write | bool | 如果设置为 |
Method: save(stream)
save(stream)
保存数据。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 用于保存图像数据的流。 |
Method: save(stream, options_base)
save(stream, options_base)
根据保存选项,将图像的数据保存到指定流中的指定文件格式。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 保存图像数据的流。 |
| options_base | ImageOptionsBase | 保存选项。 |
Method: save(stream, options_base, bounds_rectangle)
save(stream, options_base, bounds_rectangle)
根据保存选项,将图像的数据保存到指定流中的指定文件格式。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 保存图像数据的流。 |
| options_base | ImageOptionsBase | 保存选项。 |
| bounds_rectangle | Rectangle | 目标图像边界矩形。将空矩形设置为使用源边界。 |
Method: save_argb_32_pixels(rectangle, pixels)
save_argb_32_pixels(rectangle, pixels)
保存 32 位 ARGB 像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 保存像素的矩形。 |
| 像素 | int[] | 32 位 ARGB 像素数组。 |
Method: save_cmyk_32_pixels(rectangle, pixels)
save_cmyk_32_pixels(rectangle, pixels)
保存像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 保存像素的矩形。 |
| 像素 | int[] | 以 32 位整数值表示的 CMYK 像素。 |
Method: save_cmyk_pixels(rectangle, pixels)
save_cmyk_pixels(rectangle, pixels)
保存像素。
此方法已弃用。请使用更有效的 RasterImage.save_cmyk_32_pixels(rectangle, pixels) 方法。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 保存像素的矩形。 |
| pixels | CmykColor[] | CMYK 像素数组。 |
Method: save_pixels(rectangle, pixels)
save_pixels(rectangle, pixels)
保存像素的内部主要内容。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| rectangle | Rectangle | 矩形。 |
| pixels | Color[] | 像素。 |
Method: save_raw_data(data, data_offset, rectangle, raw_data_settings)
save_raw_data(data, data_offset, rectangle, raw_data_settings)
保存原始数据。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 数据 | System.Byte | 原始数据。 |
| data_offset | int | 起始原始数据偏移。 |
| rectangle | Rectangle | 原始数据矩形。 |
| raw_data_settings | RawDataSettings | 原始数据所在的设置。 |
Method: save_to_stream(stream)
save_to_stream(stream)
将对象的数据保存到指定的流中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 用于保存对象数据的流。 |
Method: save_to_stream_with_options(stream, options_base)
save_to_stream_with_options(stream, options_base)
根据保存选项,将图像的数据保存到指定流中的指定文件格式。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 保存图像数据的流。 |
| options_base | ImageOptionsBase | 保存选项。 |
Method: save_to_stream_with_options_rect(stream, options_base, bounds_rectangle)
save_to_stream_with_options_rect(stream, options_base, bounds_rectangle)
根据保存选项,将图像的数据保存到指定流中的指定文件格式。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| 流 | _io.BufferedRandom | 保存图像数据的流。 |
| options_base | ImageOptionsBase | 保存选项。 |
| bounds_rectangle | Rectangle | 目标图像边界矩形。将空矩形设置为使用源边界。 |
Method: save_with_options(file_path, options)
save_with_options(file_path, options)
根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 文件路径。 |
| options | ImageOptionsBase | 选项。 |
Method: save_with_options_rect(file_path, options, bounds_rectangle)
save_with_options_rect(file_path, options, bounds_rectangle)
根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| file_path | string | 文件路径。 |
| options | ImageOptionsBase | 选项。 |
| bounds_rectangle | Rectangle | 目标图像边界矩形。将空矩形设置为使用源边界。 |
Method: set_argb_32_pixel(x, y, argb_32_color)
set_argb_32_pixel(x, y, argb_32_color)
为指定位置设置图像的 32 位 ARGB 像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| x | int | 像素的 x 位置。 |
| y | int | 像素的 y 位置。 |
| argb_32_color | int | 指定位置的 32 位 ARGB 像素。 |
Method: set_palette(palette, update_colors)
set_palette(palette, update_colors)
设置图像调色板。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| palette | IColorPalette | 要设置的调色板。 |
| update_colors | bool | 如果设置为 |
Method: set_pixel(x, y, color)
set_pixel(x, y, color)
为指定位置设置图像像素。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| x | int | 像素的 x 位置。 |
| y | int | 像素的 y 位置。 |
| color | Color | 指定位置的像素颜色。 |
Method: set_resolution(dpi_x, dpi_y)
set_resolution(dpi_x, dpi_y)
为此 RasterImage 设置分辨率。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| dpi_x | float | 以每英寸点数表示的 RasterImage 的水平分辨率。 |
| dpi_y | float | 以每英寸点数表示的 RasterImage 的垂直分辨率。 |
Method: try_set_metadata(metadata)
try_set_metadata(metadata)
尝试设置一个 metadata 实例,前提是此 Image 实例支持并实现 IImageMetadataFormat 实例。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| metadata | IImageMetadataFormat | 元数据。 |
Returns
| Type | Description |
|---|---|
| bool | 如果 metadata 不为 null 且 IMetadataContainer 实例 支持和/或实现 IImageMetadataFormat 实例,则为 true;否则为 false。 |
Method: write_argb_32_scan_line(scan_line_index, argb_32_pixels)
write_argb_32_scan_line(scan_line_index, argb_32_pixels)
将整条扫描线写入指定的扫描线索引。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| scan_line_index | int | 扫描线的零基索引。 |
| argb_32_pixels | int[] | 要写入的 32 位 ARGB 颜色数组。 |
Method: write_scan_line(scan_line_index, pixels)
write_scan_line(scan_line_index, pixels)
将整条扫描线写入指定的扫描线索引。
Parameters:
| 参数 | Type | Description |
|---|---|---|
| scan_line_index | int | 扫描线的零基索引。 |
| pixels | Color[] | 要写入的像素颜色数组。 |
Examples
This example shows how to load a WebP image from a file and save it to PNG.
import aspose.pycore as aspycore
from aspose.imaging.fileformats.webp import WebPImage
from aspose.imaging.imageoptions import PngOptions
from os.path import join
dir_ = "c:\\temp"
# 从文件加载 WebP 图像。
with WebPImage(join(dir_, "test.webp")) as web_pimage:
# 保存为 PNG
# 请注意,由于 PNG 不是多页格式,只有活动帧会被保存为 PNG。
web_pimage.save(join(dir_, "test.output.png"), PngOptions())
This example shows how to load a WebP image from a file stream and save it to PNG.
import aspose.pycore as aspycore
from aspose.imaging.fileformats.webp import WebPImage
from aspose.imaging.imageoptions import PngOptions
from os.path import join
dir_: str = "c:\\temp"
# 从文件流加载 WebP 图像。
with open(join(dir_, "test.webp"), "w+b") as stream:
with WebPImage(stream) as web_pimage:
# 保存为 PNG
# 请注意,由于 PNG 不是多页格式,只有活动帧会被保存为 PNG。
web_pimage.save(join(dir_, "test.output.png"), PngOptions())
This example shows how to create a WebP image from another raster image.
from os.path import join
from aspose.imaging import Graphics, Color
from aspose.imaging.fileformats.png import PngImage
from aspose.imaging.fileformats.webp import WebPImage
from aspose.imaging.brushes import SolidBrush
from aspose.imaging.imageoptions import WebPOptions
dir_: str = "c:\\temp"
# 加载 100x100 像素的 PNG 图像。
with PngImage(100, 100) as png_image:
graphics = Graphics(png_image)
# 将整幅图像填充为红色。
brush = SolidBrush(Color.red)
graphics.fill_rectangle(brush, png_image.bounds)
# 基于 PNG 图像创建 WebP 图像。
with WebPImage(png_image) as web_pimage:
# 使用默认选项保存为 WebP 文件
web_pimage.save(join(dir_, "output.webp"), WebPOptions())
This example shows how to create a WebP image with the specified options from scratch.
from aspose.imaging.fileformats.webp import WebPImage
from aspose.imaging import Graphics, Color
from aspose.imaging.brushes import SolidBrush
from aspose.imaging.imageoptions import WebPOptions
from os.path import join
dir_: str = "c:\\temp"
create_options = WebPOptions()
create_options.lossless = True
create_options.quality = 100.0
# 创建 100x100 像素的 WebP 图像。
with WebPImage(100, 100, create_options) as web_pimage:
graphics = Graphics(web_pimage)
# 将整幅图像填充为红色。
brush = SolidBrush(Color.red)
graphics.fill_rectangle(brush, web_pimage.bounds)
# 保存为 WebP 文件
web_pimage.save(join(dir_, "output.webp"))
The following example loads a WEBP image and prints information about raw data format and alpha channel.
import aspose.pycore as aspycore
from aspose.imaging import Image
from aspose.imaging.fileformats.webp import WebPImage, WebPFrameBlock
dir_ = "c:\\temp"
file_name = dir_ + "sample.webp"
with Image.load(file_name) as image:
webp_image = aspycore.as_of(image, WebPImage)
# 如果活动的 TIFF 帧具有 alpha 通道,则整个 TIFF 图像被视为具有 alpha 通道。
print(f"ImageFile={file_name}, FileFormat={webp_image.raw_data_format}, HasAlpha={webp_image.has_alpha}")
i: int = 0
for frame in webp_image.blocks:
if aspycore.is_assignable(frame, WebPFrameBlock):
frame_block = aspycore.as_of(frame, WebPFrameBlock)
print(f"Frame={i}, FileFormat={frame_block.raw_data_format}, HasAlpha={frame_block.has_alpha}")
i += 1
# 输出可能如下所示:
# ImageFile=c:\temp\sample.webp, FileFormat=RgbIndexed1Bpp, 使用的通道: 1, HasAlpha=False
# Frame=0, FileFormat=RgbIndexed1Bpp, 使用的通道: 1, HasAlpha=False