WmfImage 类

Summary: Manipulate Microsoft Windows Metafile (WMF) images with our API, seamlessly
handling both vector and bitmap data stored within variable-length records.
Resize, rotate, and flip images with ease while setting custom image palettes.
Convert WMF files to compressed WMZ formats or save them in raster image formats
for versatile usage across platforms and applications.

Module: aspose.imaging.fileformats.wmf

Full Name: aspose.imaging.fileformats.wmf.WmfImage

Inheritance: IObjectWithBounds, IMetadataContainer, IHasExifData, IHasMetadata, IHasXmpData, IObjectWithSizeF, MetaImage

Constructors

Name描述
WmfImage()创建 WmfImage 类的新实例,以便
进一步操作和处理 Windows Metafile (WMF) 图像数据。此
构造函数提供了用于处理 WMF 图像的基础对象,使得
能够将 WMF 图像处理功能无缝集成到您的应用程序的
功能中。
WmfImage(width, height)实例化 WmfImage 类的新对象,可自定义
宽度和高度参数,以便创建符合特定尺寸的空白 WMF 图像。使用此构造函数可动态生成
具有精确尺寸的 WMF 图像,实现灵活的图像创建和
在您的应用程序中进行操作。

Properties

NameTypeAccess描述
auto_adjust_paletteboolr/w获取或设置一个值,指示是否自动调整调色板。
background_colorColorr/w获取或设置背景颜色的值。
bits_per_pixelintr检索图像的每像素位数,表示颜色深度或粒度水平。利用此属性确定图像的颜色
表示和精度,帮助进行兼容性检查和与颜色相关的
处理。
boundsRectangler获取对象的边界。
buffer_size_hintintr/w获取或设置缓冲区大小提示,该提示定义了所有内部缓冲区的最大允许大小。
containerImager获取 Image 容器。
data_stream_containerStreamContainerr获取对象的数据流。
disposedboolr获取一个值,指示此实例是否已释放。
exif_dataExifDatar/w获取或设置 Exif 实例。
file_formatFileFormatr访问与图像关联的文件格式值,提供关于
图像存储格式的信息。利用此属性确定
图像的文件格式,便于兼容性检查和
在您的应用程序中的特定格式处理。
frame_boundsRectangler访问帧的边界,指示其在图像中的位置和尺寸。利用此属性获取帧的空间位置的详细信息,
实现精确的操作和渲染。
has_background_colorboolr/w获取或设置指示图像是否具有背景颜色的值。
heightintr获取对象的高度。
height_ffloatr访问图像的高度,表示垂直轴上的像素数量。利用此属性确定图像的空间尺寸和宽高比,
实现准确的布局和渲染调整。
英寸intr/w访问或修改 inch 属性,该属性表示通常用于在打印或显示环境中指定物理尺寸的单位。利用此
属性设置或获取与图像关联的英寸值,
以在您的应用程序中实现物理尺寸的准确表示。
interrupt_monitorInterruptMonitorr/w获取或设置中断监视器。
is_cachedboolr检索一个布尔值,指示对象的数据是否已缓存,
从而消除额外的数据读取操作。利用此属性通过判断对象的数据是否已随时可用,
来优化性能,避免在您的应用程序中进行昂贵的数据检索过程。
metadataImageMetadatar获取图像元数据。
paletteIColorPaletter/w获取或设置颜色调色板。当像素直接表示时,不使用颜色调色板。
recordsMetaObjectListr/w获取或设置记录。
sizeSizer获取对象大小。
size_fSizeFr获取对象的尺寸(单位为英寸)。
use_paletteboolr获取一个值,指示是否使用图像调色板。
widthintr获取对象的宽度。
width_ffloatr访问图像的宽度,表示水平轴上的像素数量。利用此属性确定图像的空间尺寸
和宽高比,
在您的应用程序中实现精确的布局和渲染调整。
xmp_dataXmpPacketWrapperr/w获取或设置 Xmp 数据。

Methods

Name描述
add_record(record)将指定的记录对象合并到图像中,使用
额外的数据或元数据丰富其内容。利用此方法将记录
对象无缝集成到图像中,帮助在您的应用程序中实现全面的数据存储和组织。
cache_data()高效地缓存数据,消除从底层 DataStreamSupporter.data_stream_container 进行额外加载的需求。利用此
方法通过存储和访问本地数据缓存来优化性能并降低资源使用。
can_load(file_path)确定是否可以从指定的文件路径加载图像。
can_load(file_path, load_options)确定是否可以从指定的文件路径加载图像,并可选地使用指定的打开选项。
can_load(stream)确定是否可以从指定的流加载图像。
can_load(stream, load_options)确定是否可以从指定的流加载图像,并可选地使用指定的 loadOptions
can_load_stream(stream)确定是否可以从指定的流加载图像。
can_load_stream_with_options(stream, load_options)确定是否可以从指定的流加载图像,并可选地使用指定的 loadOptions
can_load_with_options(file_path, load_options)确定是否可以从指定的文件路径加载图像,并可选地使用指定的打开选项。
can_save(options)确定是否可以将图像保存为由传入的保存选项表示的指定文件格式。
create(files)创建包含指定文件的多页图像。
create(files, throw_exception_on_load_error)创建包含指定文件的多页图像。
create(image_options, width, height)使用指定的创建选项创建新图像。
create(image_options, width, height, pixels)创建一个来自提供的像素数组的 RasterImage 实例。

验证指定的宽度和高度是否与像素数据的维度匹配。
仅当库处于授权模式时才能使用此方法。
create(images)使用指定的图像作为页面创建新图像。
create(images, dispose_images)创建一个新图像,将指定的图像作为页面。
create(multipage_create_options)创建指定的多页创建选项。
create_from_files(files)创建包含指定文件的多页图像,将其作为延迟加载页面。
create_from_files(files, throw_exception_on_load_error)创建包含指定文件的多页图像,将其作为延迟加载页面。
create_from_images(images)使用指定的图像作为页面创建新图像。
create_from_images(images, dispose_images)创建一个新图像,将指定的图像作为页面。
crop(left_shift, right_shift, top_shift, bottom_shift)使用位移裁剪图像。
crop(rectangle)裁剪指定的矩形。
get_default_options(args)获取默认图像选项。
get_embedded_images()获取嵌入的图像。
get_file_format(file_path)获取文件格式。
get_file_format(stream)获取文件格式。
get_file_format_of_stream(stream)获取文件格式。
get_fitting_rectangle(rectangle, pixels, width, height)获取适合当前图像的矩形。
get_fitting_rectangle(rectangle, width, height)获取适合当前图像的矩形。
get_missed_fonts()返回在元文件中使用但未找到的字体列表。
get_original_options()获取原始图像选项。
get_post_script()访问与图像关联的 PostScript 数据,提供有关其结构或内容的详细
信息。利用此方法检索
PostScript 数据,以便在您的应用程序中进行进一步分析或处理,
实现与 PostScript 渲染或操作相关的高级功能。
get_proportional_height(width, height, new_width)获取比例高度。
get_proportional_width(width, height, new_height)获取比例宽度。
get_serialized_stream(image_options, clipping_rectangle, page_number)转换为 aps。
get_used_fonts()检索在元文件中使用的字体列表,提供对
图像中使用的字体资源的洞察。利用此方法分析字体使用情况
并确保在您的应用程序中进行渲染或进一步处理时字体可用。
load(file_path)从指定的文件路径或 URL 加载新图像。
如果 filePath 是文件路径,方法仅打开该文件。
如果 filePath 是 URL,方法会下载文件,将其存为临时文件,然后打开它。
load(file_path, load_options)从指定的文件路径或 URL 加载新图像。
如果 filePath 是文件路径,方法仅打开该文件。
如果 filePath 是 URL,方法会下载文件,将其存为临时文件,然后打开它。
load(stream)从指定的流加载新图像。
load(stream, load_options)从指定的流加载新图像。
load_stream(stream)从指定的流加载新图像。
load_stream_with_options(stream, load_options)从指定的流加载新图像。
load_with_options(file_path, load_options)从指定的文件路径或 URL 加载新图像。
如果 filePath 是文件路径,方法仅打开该文件。
如果 filePath 是 URL,方法会下载文件,将其存为临时文件,然后打开它。
remove_background()移除背景。
remove_background(settings)移除背景。
remove_metadata()移除元数据。
resize(new_width, new_height)调整图像大小。使用默认的 ResizeType.NEAREST_NEIGHBOUR_RESAMPLE
resize(new_width, new_height, resize_type)调整指定的新宽度。
resize(new_width, new_height, settings)使用扩展选项调整图像大小。
resize_by_settings(new_width, new_height, settings)调整图像大小。
resize_by_type(new_width, new_height, resize_type)调整图像大小。
resize_canvas(new_rectangle)调整图像的画布大小,在保持图像
内容的同时修改其尺寸。利用此方法在不更改
内容的情况下修改画布大小,便于在您的
应用程序中进行布局调整和构图更改。
resize_height_proportionally(new_height)按比例调整高度。默认使用 ResizeType.NEAREST_NEIGHBOUR_RESAMPLE
resize_height_proportionally(new_height, resize_type)按比例调整高度。
resize_height_proportionally(new_height, settings)按比例调整高度。
resize_height_proportionally_settings(new_height, settings)按比例调整高度。
resize_width_proportionally(new_width)按比例调整宽度。默认使用 ResizeType.NEAREST_NEIGHBOUR_RESAMPLE
resize_width_proportionally(new_width, resize_type)按比例调整宽度。
resize_width_proportionally(new_width, settings)按比例调整宽度。
resize_width_proportionally_settings(new_width, settings)按比例调整宽度。
rotate(angle)围绕中心旋转图像。
rotate_flip(rotate_flip_type)旋转、翻转或同时旋转和翻转图像。
save()将图像数据保存到底层流中。
save(file_path)将图像保存到指定的文件位置。
save(file_path, options)根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。
save(file_path, options, bounds_rectangle)根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。
save(file_path, over_write)将对象的数据保存到指定的文件位置。
save(stream)将数据保存到指定的 stream
save(stream, options_base)根据保存选项,将图像的数据保存到指定流中的指定文件格式。
save(stream, options_base, bounds_rectangle)根据保存选项,将图像的数据保存到指定流中的指定文件格式。
save_to_stream(stream)将对象的数据保存到指定的流中。
save_to_stream_with_options(stream, options_base)根据保存选项,将图像的数据保存到指定流中的指定文件格式。
save_to_stream_with_options_rect(stream, options_base, bounds_rectangle)根据保存选项,将图像的数据保存到指定流中的指定文件格式。
save_with_options(file_path, options)根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。
save_with_options_rect(file_path, options, bounds_rectangle)根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。
set_palette(palette, update_colors)将指定的调色板应用于图像,启用颜色
表现的自定义。利用此方法提升视觉渲染并在您的应用程序中实现
特定的颜色效果。
try_set_metadata(metadata)尝试设置一个 metadata 实例,前提是此 Image 实例支持并实现 IImageMetadataFormat 实例。

Constructor: WmfImage()

 WmfImage() 

创建 WmfImage 类的新实例,以便
进一步操作和处理 Windows Metafile (WMF) 图像数据。此
构造函数提供了用于处理 WMF 图像的基础对象,使得
能够将 WMF 图像处理功能无缝集成到您的应用程序的
功能中。

Constructor: WmfImage(width, height)

 WmfImage(width, height) 

实例化 WmfImage 类的新对象,可自定义
宽度和高度参数,以便创建符合特定尺寸的空白 WMF 图像。使用此构造函数可动态生成
具有精确尺寸的 WMF 图像,实现灵活的图像创建和
在您的应用程序中进行操作。

Parameters:

参数TypeDescription
widthint宽度。
heightint高度。

Method: add_record(record)

 add_record(record) 

将指定的记录对象合并到图像中,使用
额外的数据或元数据丰富其内容。利用此方法将记录
对象无缝集成到图像中,帮助在您的应用程序中实现全面的数据存储和组织。

Parameters:

参数TypeDescription
recordWmfObject该记录。

Returns

TypeDescription
int记录数量。

Method: can_load(file_path) [static]

 can_load(file_path) 

确定是否可以从指定的文件路径加载图像。

Parameters:

参数TypeDescription
file_pathstring文件路径。

Returns

TypeDescription
booltrue 如果可以从指定文件加载图像;否则为 false

Method: can_load(file_path, load_options) [static]

 can_load(file_path, load_options) 

确定是否可以从指定的文件路径加载图像,并可选地使用指定的打开选项。

Parameters:

参数TypeDescription
file_pathstring文件路径。
load_optionsLoadOptions加载选项。

Returns

TypeDescription
booltrue 如果可以从指定文件加载图像;否则为 false

Method: can_load(stream) [static]

 can_load(stream) 

确定是否可以从指定的流加载图像。

Parameters:

参数TypeDescription
_io.BufferedRandom要加载的流。

Returns

TypeDescription
booltrue 如果可以从指定流加载图像;否则为 false

Method: can_load(stream, load_options) [static]

 can_load(stream, load_options) 

确定是否可以从指定的流加载图像,并可选地使用指定的 loadOptions

Parameters:

参数TypeDescription
_io.BufferedRandom要加载的流。
load_optionsLoadOptions加载选项。

Returns

TypeDescription
booltrue 如果可以从指定流加载图像;否则为 false

Method: can_load_stream(stream) [static]

 can_load_stream(stream) 

确定是否可以从指定的流加载图像。

Parameters:

参数TypeDescription
_io.BufferedRandom要加载的流。

Returns

TypeDescription
booltrue 如果可以从指定流加载图像;否则为 false

Method: can_load_stream_with_options(stream, load_options) [static]

 can_load_stream_with_options(stream, load_options) 

确定是否可以从指定的流加载图像,并可选地使用指定的 loadOptions

Parameters:

参数TypeDescription
_io.BufferedRandom要加载的流。
load_optionsLoadOptions加载选项。

Returns

TypeDescription
booltrue 如果可以从指定流加载图像;否则为 false

Method: can_load_with_options(file_path, load_options) [static]

 can_load_with_options(file_path, load_options) 

确定是否可以从指定的文件路径加载图像,并可选地使用指定的打开选项。

Parameters:

参数TypeDescription
file_pathstring文件路径。
load_optionsLoadOptions加载选项。

Returns

TypeDescription
booltrue 如果可以从指定文件加载图像;否则为 false

Method: can_save(options)

 can_save(options) 

确定是否可以将图像保存为由传入的保存选项表示的指定文件格式。

Parameters:

参数TypeDescription
optionsImageOptionsBase要使用的保存选项。

Returns

TypeDescription
booltrue 如果图像可以保存为由传入的保存选项表示的指定文件格式;否则为 false

Method: create(files) [static]

 create(files) 

创建包含指定文件的多页图像。

Parameters:

参数TypeDescription
文件string[]文件。

Returns

TypeDescription
Image多页图像

Method: create(files, throw_exception_on_load_error) [static]

 create(files, throw_exception_on_load_error) 

创建包含指定文件的多页图像。

Parameters:

参数TypeDescription
文件string[]文件。
throw_exception_on_load_errorbool如果设置为 true [throw exception on load error]。

Returns

TypeDescription
Image多页图像

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

 create(image_options, width, height) 

使用指定的创建选项创建新图像。

Parameters:

参数TypeDescription
image_optionsImageOptionsBase图像选项。
widthint宽度。
heightint高度。

Returns

TypeDescription
Image新创建的图像。

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

 create(image_options, width, height, pixels) 

创建一个来自提供的像素数组的 RasterImage 实例。

验证指定的宽度和高度是否与像素数据的维度匹配。
仅当库处于授权模式时才能使用此方法。

Parameters:

参数TypeDescription
image_optionsImageOptionsBase用于创建 RasterImage 的选项。
widthintRasterImage 的宽度。
heightintRasterImage 的高度。
像素int[]用于填充图像的像素值数组。

Returns

TypeDescription
Image使用提供的像素数据填充的 RasterImage

Method: create(images) [static]

 create(images) 

使用指定的图像作为页面创建新图像。

Parameters:

参数TypeDescription
imagesImage[]图像。

Returns

TypeDescription
ImageImage 作为 IMultipageImage

Method: create(images, dispose_images) [static]

 create(images, dispose_images) 

创建一个新图像,将指定的图像作为页面。

Parameters:

参数TypeDescription
imagesImage[]图像。
dispose_imagesbool如果设置为 true [dispose images]。

Returns

TypeDescription
ImageImage 作为 IMultipageImage

Method: create(multipage_create_options) [static]

 create(multipage_create_options) 

创建指定的多页创建选项。

Parameters:

参数TypeDescription
multipage_create_optionsMultipageCreateOptions多页创建选项。

Returns

TypeDescription
Image多页图像

Method: create_from_files(files) [static]

 create_from_files(files) 

创建包含指定文件的多页图像,将其作为延迟加载页面。

Parameters:

参数TypeDescription
文件string[]文件。

Returns

TypeDescription
Image多页图像

Method: create_from_files(files, throw_exception_on_load_error) [static]

 create_from_files(files, throw_exception_on_load_error) 

创建包含指定文件的多页图像,将其作为延迟加载页面。

Parameters:

参数TypeDescription
文件string[]文件。
throw_exception_on_load_errorbool如果设置为 true 抛出加载错误异常。

Returns

TypeDescription
Image多页图像

Method: create_from_images(images) [static]

 create_from_images(images) 

使用指定的图像作为页面创建新图像。

Parameters:

参数TypeDescription
imagesImage[]图像。

Returns

TypeDescription
ImageImage 作为 IMultipageImage

Method: create_from_images(images, dispose_images) [static]

 create_from_images(images, dispose_images) 

创建一个新图像,将指定的图像作为页面。

Parameters:

参数TypeDescription
imagesImage[]图像。
dispose_imagesbool如果设置为 true [dispose images]。

Returns

TypeDescription
ImageImage 作为 IMultipageImage

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

 crop(left_shift, right_shift, top_shift, bottom_shift) 

使用位移裁剪图像。

Parameters:

参数TypeDescription
left_shiftint左移。
right_shiftint右移。
top_shiftint上移。
bottom_shiftint下移。

Method: crop(rectangle)

 crop(rectangle) 

裁剪指定的矩形。

Parameters:

参数TypeDescription
rectangleRectangle矩形。

Method: get_default_options(args)

 get_default_options(args) 

获取默认图像选项。

Parameters:

参数TypeDescription
argsSystem.Object参数。

Returns

TypeDescription
ImageOptionsBase默认图像选项。

Method: get_embedded_images()

 get_embedded_images() 

获取嵌入的图像。

Returns

TypeDescription
EmbeddedImage[]图像数组

Method: get_file_format(file_path) [static]

 get_file_format(file_path) 

获取文件格式。

Parameters:

参数TypeDescription
file_pathstring文件路径。

Returns

TypeDescription
FileFormat确定的文件格式。

Method: get_file_format(stream) [static]

 get_file_format(stream) 

获取文件格式。

Parameters:

参数TypeDescription
_io.BufferedRandom该流。

Returns

TypeDescription
FileFormat确定的文件格式。

Method: get_file_format_of_stream(stream) [static]

 get_file_format_of_stream(stream) 

获取文件格式。

Parameters:

参数TypeDescription
_io.BufferedRandom该流。

Returns

TypeDescription
FileFormat确定的文件格式。

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

 get_fitting_rectangle(rectangle, pixels, width, height) 

获取适合当前图像的矩形。

Parameters:

参数TypeDescription
rectangleRectangle用于获取合适矩形的矩形。
像素int[]32 位 ARGB 像素。
widthint对象宽度。
heightint对象高度。

Returns

TypeDescription
Rectangle适配矩形,若未找到适配矩形则抛出异常。

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

 get_fitting_rectangle(rectangle, width, height) 

获取适合当前图像的矩形。

Parameters:

参数TypeDescription
rectangleRectangle用于获取合适矩形的矩形。
widthint对象宽度。
heightint对象高度。

Returns

TypeDescription
Rectangle适配矩形,若未找到适配矩形则抛出异常。

Method: get_missed_fonts()

 get_missed_fonts() 

返回在元文件中使用但未找到的字体列表。

Returns

TypeDescription
string[]字体列表

Method: get_original_options()

 get_original_options() 

获取原始图像选项。

Returns

TypeDescription
ImageOptionsBase原始图像选项。

Method: get_post_script()

 get_post_script() 

访问与图像关联的 PostScript 数据,提供有关其结构或内容的详细
信息。利用此方法检索
PostScript 数据,以便在您的应用程序中进行进一步分析或处理,
实现与 PostScript 渲染或操作相关的高级功能。

Returns

TypeDescription
string该 PostScript

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

 get_proportional_height(width, height, new_width) 

获取比例高度。

Parameters:

参数TypeDescription
widthint宽度。
heightint高度。
new_widthint新的宽度。

Returns

TypeDescription
int比例高度。

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

 get_proportional_width(width, height, new_height) 

获取比例宽度。

Parameters:

参数TypeDescription
widthint宽度。
heightint高度。
new_heightint新的高度。

Returns

TypeDescription
int比例宽度。

Method: get_serialized_stream(image_options, clipping_rectangle, page_number)

 get_serialized_stream(image_options, clipping_rectangle, page_number) 

转换为 aps。

Parameters:

参数TypeDescription
image_optionsImageOptionsBase图像选项。
clipping_rectangleRectangle裁剪矩形。
page_numberint[]页码。

Returns

TypeDescription
_io.BufferedRandom序列化流

Method: get_used_fonts()

 get_used_fonts() 

检索在元文件中使用的字体列表,提供对
图像中使用的字体资源的洞察。利用此方法分析字体使用情况
并确保在您的应用程序中进行渲染或进一步处理时字体可用。

Returns

TypeDescription
string[]字体列表

Method: load(file_path) [static]

 load(file_path) 

从指定的文件路径或 URL 加载新图像。
如果 filePath 是文件路径,方法仅打开该文件。
如果 filePath 是 URL,方法会下载文件,将其存为临时文件,然后打开它。

Parameters:

参数TypeDescription
file_pathstring加载图像的文件路径或 URL。

Returns

TypeDescription
Image已加载的图像。

Method: load(file_path, load_options) [static]

 load(file_path, load_options) 

从指定的文件路径或 URL 加载新图像。
如果 filePath 是文件路径,方法仅打开该文件。
如果 filePath 是 URL,方法会下载文件,将其存为临时文件,然后打开它。

Parameters:

参数TypeDescription
file_pathstring加载图像的文件路径或 URL。
load_optionsLoadOptions加载选项。

Returns

TypeDescription
Image已加载的图像。

Method: load(stream) [static]

 load(stream) 

从指定的流加载新图像。

Parameters:

参数TypeDescription
_io.BufferedRandom加载图像的流。

Returns

TypeDescription
Image已加载的图像。

Method: load(stream, load_options) [static]

 load(stream, load_options) 

从指定的流加载新图像。

Parameters:

参数TypeDescription
_io.BufferedRandom加载图像的流。
load_optionsLoadOptions加载选项。

Returns

TypeDescription
Image已加载的图像。

Method: load_stream(stream) [static]

 load_stream(stream) 

从指定的流加载新图像。

Parameters:

参数TypeDescription
_io.BufferedRandom加载图像的流。

Returns

TypeDescription
Image已加载的图像。

Method: load_stream_with_options(stream, load_options) [static]

 load_stream_with_options(stream, load_options) 

从指定的流加载新图像。

Parameters:

参数TypeDescription
_io.BufferedRandom加载图像的流。
load_optionsLoadOptions加载选项。

Returns

TypeDescription
Image已加载的图像。

Method: load_with_options(file_path, load_options) [static]

 load_with_options(file_path, load_options) 

从指定的文件路径或 URL 加载新图像。
如果 filePath 是文件路径,方法仅打开该文件。
如果 filePath 是 URL,方法会下载文件,将其存为临时文件,然后打开它。

Parameters:

参数TypeDescription
file_pathstring加载图像的文件路径或 URL。
load_optionsLoadOptions加载选项。

Returns

TypeDescription
Image已加载的图像。

Method: remove_background(settings)

 remove_background(settings) 

移除背景。

Parameters:

参数TypeDescription
settingsRemoveBackgroundSettings设置。

Method: resize(new_width, new_height)

 resize(new_width, new_height) 

调整图像大小。使用默认的 ResizeType.NEAREST_NEIGHBOUR_RESAMPLE

Parameters:

参数TypeDescription
new_widthint新的宽度。
new_heightint新的高度。

Method: resize(new_width, new_height, resize_type)

 resize(new_width, new_height, resize_type) 

调整指定的新宽度。

Parameters:

参数TypeDescription
new_widthint新的宽度。
new_heightint新的高度。
resize_typeResizeType调整大小的类型。

Method: resize(new_width, new_height, settings)

 resize(new_width, new_height, settings) 

使用扩展选项调整图像大小。

Parameters:

参数TypeDescription
new_widthint新的宽度。
new_heightint新的高度。
settingsImageResizeSettings调整大小设置。

Method: resize_by_settings(new_width, new_height, settings)

 resize_by_settings(new_width, new_height, settings) 

调整图像大小。

Parameters:

参数TypeDescription
new_widthint新的宽度。
new_heightint新的高度。
settingsImageResizeSettings调整大小设置。

Method: resize_by_type(new_width, new_height, resize_type)

 resize_by_type(new_width, new_height, resize_type) 

调整图像大小。

Parameters:

参数TypeDescription
new_widthint新的宽度。
new_heightint新的高度。
resize_typeResizeType调整大小类型。

Method: resize_canvas(new_rectangle)

 resize_canvas(new_rectangle) 

调整图像的画布大小,在保持图像
内容的同时修改其尺寸。利用此方法在不更改
内容的情况下修改画布大小,便于在您的
应用程序中进行布局调整和构图更改。

Parameters:

参数TypeDescription
new_rectangleRectangle新的矩形。

Method: resize_height_proportionally(new_height)

 resize_height_proportionally(new_height) 

按比例调整高度。默认使用 ResizeType.NEAREST_NEIGHBOUR_RESAMPLE

Parameters:

参数TypeDescription
new_heightint新的高度。

Method: resize_height_proportionally(new_height, resize_type)

 resize_height_proportionally(new_height, resize_type) 

按比例调整高度。

Parameters:

参数TypeDescription
new_heightint新的高度。
resize_typeResizeType调整大小的类型。

Method: resize_height_proportionally(new_height, settings)

 resize_height_proportionally(new_height, settings) 

按比例调整高度。

Parameters:

参数TypeDescription
new_heightint新的高度。
settingsImageResizeSettings图像调整大小设置。

Method: resize_height_proportionally_settings(new_height, settings)

 resize_height_proportionally_settings(new_height, settings) 

按比例调整高度。

Parameters:

参数TypeDescription
new_heightint新的高度。
settingsImageResizeSettings图像调整大小设置。

Method: resize_width_proportionally(new_width)

 resize_width_proportionally(new_width) 

按比例调整宽度。默认使用 ResizeType.NEAREST_NEIGHBOUR_RESAMPLE

Parameters:

参数TypeDescription
new_widthint新的宽度。

Method: resize_width_proportionally(new_width, resize_type)

 resize_width_proportionally(new_width, resize_type) 

按比例调整宽度。

Parameters:

参数TypeDescription
new_widthint新的宽度。
resize_typeResizeType调整大小的类型。

Method: resize_width_proportionally(new_width, settings)

 resize_width_proportionally(new_width, settings) 

按比例调整宽度。

Parameters:

参数TypeDescription
new_widthint新的宽度。
settingsImageResizeSettings图像调整大小设置。

Method: resize_width_proportionally_settings(new_width, settings)

 resize_width_proportionally_settings(new_width, settings) 

按比例调整宽度。

Parameters:

参数TypeDescription
new_widthint新的宽度。
settingsImageResizeSettings图像调整大小设置。

Method: rotate(angle)

 rotate(angle) 

围绕中心旋转图像。

Parameters:

参数TypeDescription
角度float旋转角度(以度为单位)。正值将顺时针旋转。

Method: rotate_flip(rotate_flip_type)

 rotate_flip(rotate_flip_type) 

旋转、翻转或同时旋转和翻转图像。

Parameters:

参数TypeDescription
rotate_flip_typeRotateFlipType旋转翻转的类型。

Method: save(file_path)

 save(file_path) 

将图像保存到指定的文件位置。

Parameters:

参数TypeDescription
file_pathstring保存图像的文件路径。

Method: save(file_path, options)

 save(file_path, options) 

根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。

Parameters:

参数TypeDescription
file_pathstring文件路径。
optionsImageOptionsBase选项。

Method: save(file_path, options, bounds_rectangle)

 save(file_path, options, bounds_rectangle) 

根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。

Parameters:

参数TypeDescription
file_pathstring文件路径。
optionsImageOptionsBase选项。
bounds_rectangleRectangle目标图像边界矩形。将空矩形设置为使用源边界。

Method: save(file_path, over_write)

 save(file_path, over_write) 

将对象的数据保存到指定的文件位置。

Parameters:

参数TypeDescription
file_pathstring保存对象数据的文件路径。
over_writebool如果设置为 true,覆盖文件内容,否则将追加。

Method: save(stream)

 save(stream) 

将数据保存到指定的 stream

Parameters:

参数TypeDescription
_io.BufferedRandom该流。

Method: save(stream, options_base)

 save(stream, options_base) 

根据保存选项,将图像的数据保存到指定流中的指定文件格式。

Parameters:

参数TypeDescription
_io.BufferedRandom保存图像数据的流。
options_baseImageOptionsBase保存选项。

Method: save(stream, options_base, bounds_rectangle)

 save(stream, options_base, bounds_rectangle) 

根据保存选项,将图像的数据保存到指定流中的指定文件格式。

Parameters:

参数TypeDescription
_io.BufferedRandom保存图像数据的流。
options_baseImageOptionsBase保存选项。
bounds_rectangleRectangle目标图像边界矩形。将空矩形设置为使用源边界。

Method: save_to_stream(stream)

 save_to_stream(stream) 

将对象的数据保存到指定的流中。

Parameters:

参数TypeDescription
_io.BufferedRandom用于保存对象数据的流。

Method: save_to_stream_with_options(stream, options_base)

 save_to_stream_with_options(stream, options_base) 

根据保存选项,将图像的数据保存到指定流中的指定文件格式。

Parameters:

参数TypeDescription
_io.BufferedRandom保存图像数据的流。
options_baseImageOptionsBase保存选项。

Method: save_to_stream_with_options_rect(stream, options_base, bounds_rectangle)

 save_to_stream_with_options_rect(stream, options_base, bounds_rectangle) 

根据保存选项,将图像的数据保存到指定流中的指定文件格式。

Parameters:

参数TypeDescription
_io.BufferedRandom保存图像数据的流。
options_baseImageOptionsBase保存选项。
bounds_rectangleRectangle目标图像边界矩形。将空矩形设置为使用源边界。

Method: save_with_options(file_path, options)

 save_with_options(file_path, options) 

根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。

Parameters:

参数TypeDescription
file_pathstring文件路径。
optionsImageOptionsBase选项。

Method: save_with_options_rect(file_path, options, bounds_rectangle)

 save_with_options_rect(file_path, options, bounds_rectangle) 

根据保存选项,将对象的数据保存到指定文件位置的指定文件格式中。

Parameters:

参数TypeDescription
file_pathstring文件路径。
optionsImageOptionsBase选项。
bounds_rectangleRectangle目标图像边界矩形。将空矩形设置为使用源边界。

Method: set_palette(palette, update_colors)

 set_palette(palette, update_colors) 

将指定的调色板应用于图像,启用颜色
表现的自定义。利用此方法提升视觉渲染并在您的应用程序中实现
特定的颜色效果。

Parameters:

参数TypeDescription
paletteIColorPalette要设置的调色板。
update_colorsbool如果设置为 true,颜色将根据新调色板进行更新;否则颜色
索引保持不变。请注意,如果某些索引没有对应的调色板条目,未更改的索引可能导致图像在加载时崩溃。

Method: try_set_metadata(metadata)

 try_set_metadata(metadata) 

尝试设置一个 metadata 实例,前提是此 Image 实例支持并实现 IImageMetadataFormat 实例。

Parameters:

参数TypeDescription
metadataIImageMetadataFormat元数据。

Returns

TypeDescription
bool如果 metadata 不为 null 且 IMetadataContainer 实例
支持和/或实现 IImageMetadataFormat 实例,则为 true;否则为 false。

Examples

This example shows how to load a WMF image from a file and convert it to SVG using WmfRasterizationOptions.


from aspose.pycore import as_of, cast
from aspose.imaging import Image, Color, SizeF
from aspose.imaging.fileformats.wmf import WmfImage, WmfRenderMode
from aspose.imaging.imageoptions import SvgOptions, WmfRasterizationOptions

# 使用 Aspose.Imaging.Image.Load 是一种统一的方式来加载包括 WMF 在内的所有类型的图像。
with as_of(Image.load("test.wmf") as image:
	saveOptions = SvgOptions()
	# 文本将被转换为形状。
	saveOptions.text_as_shapes = True
	rasterizationOptions = WmfRasterizationOptions()
	# 绘图表面的背景颜色。
	rasterizationOptions.background_color = Color.white_smoke
	# 页面大小。
	rasterizationOptions.page_size = cast(SizeF, wmfImage.size)
	# 如果存在嵌入的 emf,则渲染 emf;否则渲染 wmf。
	rasterizationOptions.render_mode = WmfRenderMode.AUTO
	saveOptions.vector_rasterization_options = rasterizationOptions
	wmfImage.save("test.output.svg", saveOptions)

The following example shows how to convert compressed images (.emz,.wmz, *.svgz) to a raster format

from aspose.imaging import Image, Color
from aspose.imaging.imageoptions import PngOptions, VectorRasterizationOptions
from os.path import join
from aspose.pycore import as_of

files = ["example.emz", "example.wmz", "example.svgz"]
base_folder: str = join("D:", "Compressed")
for file in files:
	input_file: str = join(base_folder, file)
	out_file: str = input_file + ".png"
	with Image.load(input_file) as image:
		vector_rasterization_options = aspycore.as_of(image.get_default_options([Color.white, image.width, image.height]), VectorRasterizationOptions)
		obj_init = PngOptions()
		obj_init.vector_rasterization_options = vector_rasterization_options
		image.save(out_file, obj_init)

The following example shows how to convert a wmz images to wmf fromat

import aspose.pycore as aspycore
from aspose.imaging import Image, SizeF
from aspose.imaging.imageoptions import WmfRasterizationOptions, WmfOptions
from os.path import join

file: str = "example.wmz"
base_folder: str = join("D:", "Compressed")
input_file: str = join(base_folder, file)
out_file: str = input_file + ".wmf"
with Image.load(input_file) as image:
	obj_init = WmfRasterizationOptions()
	obj_init.page_size = aspycore.cast(SizeF, image.size)
	obj_init2 = WmfOptions()
	obj_init2.vector_rasterization_options = obj_init
	image.save(out_file, obj_init2)

The following example shows how to convert a wmf images to wmz format


from os.path import join as path_combine
import aspose.pycore as aspycore
from aspose.imaging import Image, SizeF
from aspose.imaging.imageoptions import WmfRasterizationOptions, WmfOptions

file = "castle.wmf"
base_folder = path_combine("D:", "Compressed")
input_file = path_combine(base_folder, file)
out_file = input_file + ".wmz"
with Image.load(input_file) as image:
	vector_rasterization_options = WmfRasterizationOptions()
	vector_rasterization_options.page_size = aspycore.cast(SizeF, image.size)
	obj_init2 = WmfOptions()
	obj_init2.vector_rasterization_options = vector_rasterization_options
	obj_init2.compress = True
	image.save(out_file, obj_init2)