EmfImage 类

Summary: The API for Enhanced Metafile Format (EMF) vector image format support is
a comprehensive tool for processing graphical images in a device-independent
manner while preserving their original properties. Developed to maintain
proportions, dimensions, colors, and other graphic attributes, it includes
EMF Plus format support and features for cropping regions, resizing canvas
and images, rotating, flipping, setting image palettes, exporting and importing
to APS device context, compressing and converting EMF to other formats, ensuring
versatile manipulation and seamless integration of EMF images across applications.

Module: aspose.imaging.fileformats.emf

Full Name: aspose.imaging.fileformats.emf.EmfImage

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

Constructors

Name描述
EmfImage()通过初始化一个新的实例来开始使用 EMF 图像
EmfImage 类。非常适合快速、轻松且高效地将 EMF 图像整合到
您的项目中。
EmfImage(width, height)通过指定宽度
和高度参数,创建 EmfImage 类的新实例。此构造函数简化了使用特定尺寸初始化 EMF 图像的过程,提升了开发工作流的效率。

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访问与对象关联的文件格式值。轻松确定对象关联文件的格式,以实现流畅的处理和
兼容性检查。通过轻松检索文件格式信息,简化您的工作流。
has_background_colorboolr/w获取或设置指示图像是否具有背景颜色的值。
headerEmfMetafileHeaderr/w使用此属性检索或修改 EMF 元文件头记录。
非常适合在应用程序中高效管理元文件数据。通过流畅访问元文件头信息,提升工作流。
heightintr获取对象的高度。
height_ffloatr检索图像的高度,以便实现精确的渲染和布局调整。
访问高度属性可确保在不同平台和应用程序之间的兼容性和无缝集成。
interrupt_monitorInterruptMonitorr/w获取或设置中断监视器。
is_cachedboolr访问一个值,以指示对象的数据是否已缓存,
从而消除额外读取数据的需求。通过快速确定是否有可立即访问的缓存数据来提升效率。使用流畅的数据检索过程,优化您的工作流。
metadataImageMetadatar获取图像元数据。
paletteIColorPaletter/w获取或设置颜色调色板。当像素直接表示时,不使用颜色调色板。
recordsMetaObjectListr/w检索或修改与对象关联的记录。高效访问并
管理记录集合,以增强数据操作和处理。通过无缝交互对象的记录,优化您的工作流。
sizeSizer获取对象大小。
size_fSizeFr获取对象的尺寸(单位为英寸)。
use_paletteboolr获取一个值,指示是否使用图像调色板。
widthintr获取对象的宽度。
width_ffloatr访问图像的宽度,提供精确
渲染和处理所需的关键信息。快速检索图像宽度,以确保在各种应用程序和平台中的兼容性和正确布局。
xmp_dataXmpPacketWrapperr/w获取或设置 Xmp 数据。

Methods

Name描述
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_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: EmfImage()

 EmfImage() 

通过初始化一个新的实例来开始使用 EMF 图像
EmfImage 类。非常适合快速、轻松且高效地将 EMF 图像整合到
您的项目中。

Constructor: EmfImage(width, height)

 EmfImage(width, height) 

通过指定宽度
和高度参数,创建 EmfImage 类的新实例。此构造函数简化了使用特定尺寸初始化 EMF 图像的过程,提升了开发工作流的效率。

Parameters:

参数TypeDescription
widthint宽度。
heightint高度。

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_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

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 emz images to emf format

import aspose.pycore as aspycore
from aspose.imaging import Image, SizeF
from aspose.imaging.imageoptions import EmfRasterizationOptions, EmfOptions
from os.path import join

file: str = "example.emz"
base_folder: str = join("D:", "Compressed")
input_file: str = join(base_folder, file)
out_file: str = input_file + ".emf"
with Image.load(input_file) as image:
	obj_init = EmfRasterizationOptions()
	obj_init.page_size = aspycore.cast(SizeF, image.size)
	obj_init2 = EmfOptions()
	obj_init2.vector_rasterization_options = obj_init
	image.save(out_file, obj_init2)

The following example shows how to convert a emf images to emz 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 EmfRasterizationOptions, EmfOptions

file = "input.emf"
base_folder = path_combine("D:", "Compressed")
input_file = path_combine(base_folder, file)
out_file = input_file + ".emz"
with Image.load(input_file) as image:
	vector_rasterization_options = EmfRasterizationOptions()
	vector_rasterization_options.page_size = aspycore.cast(SizeF, image.size)
	obj_init2 = EmfOptions()
	obj_init2.vector_rasterization_options = vector_rasterization_options
	obj_init2.compress = True
	image.save(out_file, obj_init2)