WmfImage Class

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, IObjectWithSizeF, MetaImage

Aspose.Imaging Version: 24.7.0

Constructors

NameDescription
WmfImage()Create a new instance of the WmfImage class, initializing it for
further manipulation and processing of Windows Metafile (WMF) image data. This
constructor provides a foundational object for working with WMF images, enabling
seamless integration of WMF image handling capabilities into your application’s
functionality.
WmfImage(width, height)Instantiate a new instance of the WmfImage class with customizable
width and height parameters, facilitating the creation of blank WMF images
tailored to specific dimensions. Utilize this constructor to dynamically generate
WMF images with precise dimensions, enabling flexible image creation and
manipulation within your application.

Properties

NameTypeAccessDescription
auto_adjust_paletteboolr/wGets or sets a value indicating whether automatic adjust palette.
background_colorColorr/wGets or sets a value for the background color.
bits_per_pixelintrRetrieve the count of bits per pixel for the image, indicating the level of color
depth or granularity. Utilize this property to determine the image’s color
representation and precision, facilitating compatibility checks and color-related
processing within your application.
boundsRectanglerGets the object bounds.
buffer_size_hintintr/wGets or sets the buffer size hint which is defined max allowed size for all internal buffers.
containerImagerGets the Image container.
data_stream_containerStreamContainerrGets the object’s data stream.
disposedboolrGets a value indicating whether this instance is disposed.
file_formatFileFormatrAccess the file format value associated with the image, providing information
about the format in which the image is stored. Utilize this property to determine
the file format of the image, facilitating compatibility checks and
format-specific processing within your application.
frame_boundsRectanglerAccess the bounds of the frame, indicating its position and dimensions within the
image. Utilize this property to retrieve detailed information about the frame’s
spatial location, enabling precise manipulation and rendering within your application.
has_background_colorboolr/wGets or sets a value indicating whether image has background color.
heightintrAccess the image’s height, representing the number of pixels along its vertical
axis. Utilize this property to ascertain the image’s spatial dimensions and aspect
ratio, enabling accurate layout and rendering adjustments within your application.
height_ffloatrGets the object height, in inches.
inchintr/wAccess or modify the inch property, representing a unit of measurement typically
used for specifying physical dimensions in print or display contexts. Utilize this
property to establish or retrieve inch values associated with the image,
facilitating accurate representation of physical dimensions within your application.
interrupt_monitorInterruptMonitorr/wGets or sets the interrupt monitor.
is_cachedboolrRetrieve a boolean value indicating whether the object’s data is currently cached,
eliminating the need for additional data reading operations. Utilize this property
to optimize performance by determining if the object’s data is readily available
without the need for costly data retrieval processes within your application.
paletteIColorPaletter/wGets or sets the color palette. The color palette is not used when pixels are represented directly.
recordsMetaObjectListr/wGets or sets the records.
sizeSizerGets the object size.
size_fSizeFrGets the object size, in inches.
use_paletteboolrGets a value indicating whether the image palette is used.
widthintrAccess the width of the image, indicating the number of pixels along its
horizontal axis. Utilize this property to determine the image’s spatial dimensions
and aspect ratio, enabling precise layout and rendering adjustments within your
application.
width_ffloatrGets the object width, in inches.

Methods

NameDescription
add_record(record)Incorporate the specified record object into the image, enriching its content with
additional data or metadata. Utilize this method to seamlessly integrate record
objects into the image, facilitating comprehensive data storage and organization
within your application.
cache_data()Efficiently cache the data, eliminating the need for additional loading from the
underlying DataStreamSupporter.data_stream_container. Utilize this
method to optimize performance and minimize resource usage within your application
by storing and accessing local data cache.
can_load(file_path)Determines whether image can be loaded from the specified file path.
can_load(file_path, load_options)Determines whether image can be loaded from the specified file path and optionally using the specified open options.
can_load(stream)Determines whether image can be loaded from the specified stream.
can_load(stream, load_options)Determines whether image can be loaded from the specified stream and optionally using the specified loadOptions.
can_load_stream(stream)Determines whether image can be loaded from the specified stream.
can_load_stream_with_options(stream, load_options)Determines whether image can be loaded from the specified stream and optionally using the specified loadOptions.
can_load_with_options(file_path, load_options)Determines whether image can be loaded from the specified file path and optionally using the specified open options.
can_save(options)Determines whether image can be saved to the specified file format represented by the passed save options.
create(image_options, width, height)Creates a new image using the specified create options.
create(images)Creates a new image using the specified images as pages
create(images, dispose_images)Creates a new image the specified images as pages.
crop(left_shift, right_shift, top_shift, bottom_shift)Crop image with shifts.
crop(rectangle)Crop the image to the specified rectangle, retaining only the selected region
while discarding the rest. Integrate this method into your image processing
workflow to extract specific areas of interest and customize the composition of
the image within your application.
get_default_options(args)Retrieve the default options associated with the image, providing access to
predefined settings or configurations. Utilize this method to access default
settings for image processing operations, facilitating consistency and convenience
within your application’s functionality.
get_embedded_images()Gets the embedded images.
get_file_format(file_path)Gets the file format.
get_file_format(stream)Gets the file format.
get_file_format_of_stream(stream)Gets the file format.
get_fitting_rectangle(rectangle, pixels, width, height)Gets rectangle which fits the current image.
get_fitting_rectangle(rectangle, width, height)Gets rectangle which fits the current image.
get_missed_fonts()Returns the list of fonts which used inside metafile but not found.
get_original_options()Gets the options based on the original file settings.
This can be helpful to keep bit-depth and other parameters of the original image unchanged.
For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the
DataStreamSupporter.save(file_path) method, the output PNG image with 8-bit per pixel will be produced.
To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them
to the Image.save(file_path, options) method as the second parameter.
get_post_script()Access the PostScript data associated with the image, providing detailed
information about its structure or content. Utilize this method to retrieve
PostScript data for further analysis or processing within your application,
enabling advanced functionality related to PostScript rendering or manipulation.
get_proportional_height(width, height, new_width)Gets a proportional height.
get_proportional_width(width, height, new_height)Gets a proportional width.
get_serialized_stream(image_options, clipping_rectangle, page_number)Converts to aps.
get_used_fonts()Retrieve the list of fonts used within the metafile, providing insight into the
font resources utilized in the image. Utilize this method to analyze font usage
and ensure font availability for rendering or further processing within your application.
load(file_path)Loads a new image from the specified file.
load(file_path, load_options)Loads a new image from the specified file.
load(stream)Loads a new image from the specified stream.
load(stream, load_options)Loads a new image from the specified stream.
load_stream(stream)Loads a new image from the specified stream.
load_stream_with_options(stream, load_options)Loads a new image from the specified stream.
load_with_options(file_path, load_options)Loads a new image from the specified file.
remove_background()Removes the background.
remove_background(settings)Removes the background.
remove_metadata()Removes metadata.
resize(new_width, new_height)Resizes the image. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.
resize(new_width, new_height, resize_type)Resizes the image.
resize(new_width, new_height, settings)Resizes the image.
resize_by_settings(new_width, new_height, settings)Resizes the image.
resize_by_type(new_width, new_height, resize_type)Resizes the image.
resize_canvas(new_rectangle)Resize the canvas of the image, adjusting its dimensions while retaining the image
content. Utilize this method to modify the size of the canvas without altering the
content, facilitating layout adjustments and composition changes within your
application.
resize_height_proportionally(new_height)Resizes the height proportionally. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.
resize_height_proportionally(new_height, resize_type)Resizes the height proportionally.
resize_height_proportionally(new_height, settings)Resizes the height proportionally.
resize_height_proportionally_settings(new_height, settings)Resizes the height proportionally.
resize_width_proportionally(new_width)Resizes the width proportionally. The default ResizeType.NEAREST_NEIGHBOUR_RESAMPLE is used.
resize_width_proportionally(new_width, resize_type)Resizes the width proportionally.
resize_width_proportionally(new_width, settings)Resizes the width proportionally.
resize_width_proportionally_settings(new_width, settings)Resizes the width proportionally.
rotate_flip(rotate_flip_type)Perform rotation, flipping, or a combination of both operations on the image.
Integrate this method into your image processing workflow to achieve precise
manipulation of image orientation and alignment within your application.
save()Saves the image data to the underlying stream.
save(file_path)Saves the image to the specified file location.
save(file_path, options)Saves the object’s data to the specified file location in the specified file format according to save options.
save(file_path, options, bounds_rectangle)Saves the object’s data to the specified file location in the specified file format according to save options.
save(file_path, over_write)Saves the object’s data to the specified file location.
save(stream)Saves the data.
save(stream, options_base)Saves the image’s data to the specified stream in the specified file format according to save options.
save(stream, options_base, bounds_rectangle)Saves the image’s data to the specified stream in the specified file format according to save options.
save_to_stream(stream)Saves the object’s data to the specified stream.
save_to_stream_with_options(stream, options_base)Saves the image’s data to the specified stream in the specified file format according to save options.
save_to_stream_with_options_rect(stream, options_base, bounds_rectangle)Saves the image’s data to the specified stream in the specified file format according to save options.
save_with_options(file_path, options)Saves the object’s data to the specified file location in the specified file format according to save options.
save_with_options_rect(file_path, options, bounds_rectangle)Saves the object’s data to the specified file location in the specified file format according to save options.
set_palette(palette, update_colors)Apply a specified palette to the image, enabling customization of color
representation. Utilize this method to enhance visual rendering and achieve
specific color effects within your application.

Constructor: WmfImage()

 WmfImage() 

Create a new instance of the WmfImage class, initializing it for
further manipulation and processing of Windows Metafile (WMF) image data. This
constructor provides a foundational object for working with WMF images, enabling
seamless integration of WMF image handling capabilities into your application’s
functionality.

Constructor: WmfImage(width, height)

 WmfImage(width, height) 

Instantiate a new instance of the WmfImage class with customizable
width and height parameters, facilitating the creation of blank WMF images
tailored to specific dimensions. Utilize this constructor to dynamically generate
WMF images with precise dimensions, enabling flexible image creation and
manipulation within your application.

Parameters:

ParameterTypeDescription
widthintThe width.
heightintThe height.

Method: add_record(record)

 add_record(record) 

Incorporate the specified record object into the image, enriching its content with
additional data or metadata. Utilize this method to seamlessly integrate record
objects into the image, facilitating comprehensive data storage and organization
within your application.

Parameters:

ParameterTypeDescription
recordWmfObjectThe record.

Returns

TypeDescription
intNumber of record.

Method: can_load(file_path) [static]

 can_load(file_path) 

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

Parameters:

ParameterTypeDescription
file_pathstringThe file path.

Returns

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

Method: can_load(file_path, load_options) [static]

 can_load(file_path, load_options) 

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

Parameters:

ParameterTypeDescription
file_pathstringThe file path.
load_optionsLoadOptionsThe load options.

Returns

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

Method: can_load(stream) [static]

 can_load(stream) 

Determines whether image can be loaded from the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load from.

Returns

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

Method: can_load(stream, load_options) [static]

 can_load(stream, load_options) 

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

Parameters:

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

Returns

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

Method: can_load_stream(stream) [static]

 can_load_stream(stream) 

Determines whether image can be loaded from the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load from.

Returns

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

Method: can_load_stream_with_options(stream, load_options) [static]

 can_load_stream_with_options(stream, load_options) 

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

Parameters:

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

Returns

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

Method: can_load_with_options(file_path, load_options) [static]

 can_load_with_options(file_path, load_options) 

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

Parameters:

ParameterTypeDescription
file_pathstringThe file path.
load_optionsLoadOptionsThe load options.

Returns

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

Method: can_save(options)

 can_save(options) 

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

Parameters:

ParameterTypeDescription
optionsImageOptionsBaseThe save options to use.

Returns

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

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

 create(image_options, width, height) 

Creates a new image using the specified create options.

Parameters:

ParameterTypeDescription
image_optionsImageOptionsBaseThe image options.
widthintThe width.
heightintThe height.

Returns

TypeDescription
ImageThe newly created image.

Method: create(images) [static]

 create(images) 

Creates a new image using the specified images as pages

Parameters:

ParameterTypeDescription
imagesImage[]The images.

Returns

TypeDescription
ImageThe Image as IMultipageImage

Method: create(images, dispose_images) [static]

 create(images, dispose_images) 

Creates a new image the specified images as pages.

Parameters:

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

Returns

TypeDescription
ImageThe Image as IMultipageImage

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

 crop(left_shift, right_shift, top_shift, bottom_shift) 

Crop image with shifts.

Parameters:

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

Method: crop(rectangle)

 crop(rectangle) 

Crop the image to the specified rectangle, retaining only the selected region
while discarding the rest. Integrate this method into your image processing
workflow to extract specific areas of interest and customize the composition of
the image within your application.

Parameters:

ParameterTypeDescription
rectangleRectangleThe rectangle.

Method: get_default_options(args)

 get_default_options(args) 

Retrieve the default options associated with the image, providing access to
predefined settings or configurations. Utilize this method to access default
settings for image processing operations, facilitating consistency and convenience
within your application’s functionality.

Parameters:

ParameterTypeDescription
argsobjectThe arguments.

Returns

TypeDescription
ImageOptionsBaseDefault options

Method: get_embedded_images()

 get_embedded_images() 

Gets the embedded images.

Returns

TypeDescription
EmbeddedImage[]Array of images

Method: get_file_format(file_path) [static]

 get_file_format(file_path) 

Gets the file format.

Parameters:

ParameterTypeDescription
file_pathstringThe file path.

Returns

TypeDescription
FileFormatThe determined file format.

Method: get_file_format(stream) [static]

 get_file_format(stream) 

Gets the file format.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream.

Returns

TypeDescription
FileFormatThe determined file format.

Method: get_file_format_of_stream(stream) [static]

 get_file_format_of_stream(stream) 

Gets the file format.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream.

Returns

TypeDescription
FileFormatThe determined file format.

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

 get_fitting_rectangle(rectangle, pixels, width, height) 

Gets rectangle which fits the current image.

Parameters:

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

Returns

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

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

 get_fitting_rectangle(rectangle, width, height) 

Gets rectangle which fits the current image.

Parameters:

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

Returns

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

Method: get_missed_fonts()

 get_missed_fonts() 

Returns the list of fonts which used inside metafile but not found.

Returns

TypeDescription
stringThe font list

Method: get_original_options()

 get_original_options() 

Gets the options based on the original file settings.
This can be helpful to keep bit-depth and other parameters of the original image unchanged.
For example, if we load a black-white PNG image with 1 bit per pixel and then save it using the
DataStreamSupporter.save(file_path) method, the output PNG image with 8-bit per pixel will be produced.
To avoid it and save PNG image with 1-bit per pixel, use this method to get corresponding saving options and pass them
to the Image.save(file_path, options) method as the second parameter.

Returns

TypeDescription
ImageOptionsBaseThe options based on the original file settings.

Method: get_post_script()

 get_post_script() 

Access the PostScript data associated with the image, providing detailed
information about its structure or content. Utilize this method to retrieve
PostScript data for further analysis or processing within your application,
enabling advanced functionality related to PostScript rendering or manipulation.

Returns

TypeDescription
stringThe post script

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

 get_proportional_height(width, height, new_width) 

Gets a proportional height.

Parameters:

ParameterTypeDescription
widthintThe width.
heightintThe height.
new_widthintThe new width.

Returns

TypeDescription
intThe proportional height.

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

 get_proportional_width(width, height, new_height) 

Gets a proportional width.

Parameters:

ParameterTypeDescription
widthintThe width.
heightintThe height.
new_heightintThe new height.

Returns

TypeDescription
intThe proportional width.

Method: get_serialized_stream(image_options, clipping_rectangle, page_number)

 get_serialized_stream(image_options, clipping_rectangle, page_number) 

Converts to aps.

Parameters:

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

Returns

TypeDescription
_io.BufferedRandomThe serialized stream

Method: get_used_fonts()

 get_used_fonts() 

Retrieve the list of fonts used within the metafile, providing insight into the
font resources utilized in the image. Utilize this method to analyze font usage
and ensure font availability for rendering or further processing within your application.

Returns

TypeDescription
stringThe font list

Method: load(file_path) [static]

 load(file_path) 

Loads a new image from the specified file.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to load image from.

Returns

TypeDescription
ImageThe loaded image.

Method: load(file_path, load_options) [static]

 load(file_path, load_options) 

Loads a new image from the specified file.

Parameters:

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

Returns

TypeDescription
ImageThe loaded image.

Method: load(stream) [static]

 load(stream) 

Loads a new image from the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load image from.

Returns

TypeDescription
ImageThe loaded image.

Method: load(stream, load_options) [static]

 load(stream, load_options) 

Loads a new image from the specified stream.

Parameters:

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

Returns

TypeDescription
ImageThe loaded image.

Method: load_stream(stream) [static]

 load_stream(stream) 

Loads a new image from the specified stream.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to load image from.

Returns

TypeDescription
ImageThe loaded image.

Method: load_stream_with_options(stream, load_options) [static]

 load_stream_with_options(stream, load_options) 

Loads a new image from the specified stream.

Parameters:

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

Returns

TypeDescription
ImageThe loaded image.

Method: load_with_options(file_path, load_options) [static]

 load_with_options(file_path, load_options) 

Loads a new image from the specified file.

Parameters:

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

Returns

TypeDescription
ImageThe loaded image.

Method: remove_background(settings)

 remove_background(settings) 

Removes the background.

Parameters:

ParameterTypeDescription
settingsRemoveBackgroundSettingsThe settings.

Method: resize(new_width, new_height)

 resize(new_width, new_height) 

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

Parameters:

ParameterTypeDescription
new_widthintThe new width.
new_heightintThe new height.

Method: resize(new_width, new_height, resize_type)

 resize(new_width, new_height, resize_type) 

Resizes the image.

Parameters:

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

Method: resize(new_width, new_height, settings)

 resize(new_width, new_height, settings) 

Resizes the image.

Parameters:

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

Method: resize_by_settings(new_width, new_height, settings)

 resize_by_settings(new_width, new_height, settings) 

Resizes the image.

Parameters:

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

Method: resize_by_type(new_width, new_height, resize_type)

 resize_by_type(new_width, new_height, resize_type) 

Resizes the image.

Parameters:

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

Method: resize_canvas(new_rectangle)

 resize_canvas(new_rectangle) 

Resize the canvas of the image, adjusting its dimensions while retaining the image
content. Utilize this method to modify the size of the canvas without altering the
content, facilitating layout adjustments and composition changes within your
application.

Parameters:

ParameterTypeDescription
new_rectangleRectangleThe new rectangle.

Method: resize_height_proportionally(new_height)

 resize_height_proportionally(new_height) 

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

Parameters:

ParameterTypeDescription
new_heightintThe new height.

Method: resize_height_proportionally(new_height, resize_type)

 resize_height_proportionally(new_height, resize_type) 

Resizes the height proportionally.

Parameters:

ParameterTypeDescription
new_heightintThe new height.
resize_typeResizeTypeType of the resize.

Method: resize_height_proportionally(new_height, settings)

 resize_height_proportionally(new_height, settings) 

Resizes the height proportionally.

Parameters:

ParameterTypeDescription
new_heightintThe new height.
settingsImageResizeSettingsThe image resize settings.

Method: resize_height_proportionally_settings(new_height, settings)

 resize_height_proportionally_settings(new_height, settings) 

Resizes the height proportionally.

Parameters:

ParameterTypeDescription
new_heightintThe new height.
settingsImageResizeSettingsThe image resize settings.

Method: resize_width_proportionally(new_width)

 resize_width_proportionally(new_width) 

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

Parameters:

ParameterTypeDescription
new_widthintThe new width.

Method: resize_width_proportionally(new_width, resize_type)

 resize_width_proportionally(new_width, resize_type) 

Resizes the width proportionally.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
resize_typeResizeTypeType of the resize.

Method: resize_width_proportionally(new_width, settings)

 resize_width_proportionally(new_width, settings) 

Resizes the width proportionally.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
settingsImageResizeSettingsThe image resize settings.

Method: resize_width_proportionally_settings(new_width, settings)

 resize_width_proportionally_settings(new_width, settings) 

Resizes the width proportionally.

Parameters:

ParameterTypeDescription
new_widthintThe new width.
settingsImageResizeSettingsThe image resize settings.

Method: rotate_flip(rotate_flip_type)

 rotate_flip(rotate_flip_type) 

Perform rotation, flipping, or a combination of both operations on the image.
Integrate this method into your image processing workflow to achieve precise
manipulation of image orientation and alignment within your application.

Parameters:

ParameterTypeDescription
rotate_flip_typeRotateFlipTypeType of the rotate flip.

Method: save(file_path)

 save(file_path) 

Saves the image to the specified file location.

Parameters:

ParameterTypeDescription
file_pathstringThe file path to save the image to.

Method: save(file_path, options)

 save(file_path, options) 

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

Parameters:

ParameterTypeDescription
file_pathstringThe file path.
optionsImageOptionsBaseThe options.

Method: save(file_path, options, bounds_rectangle)

 save(file_path, options, bounds_rectangle) 

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

Parameters:

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

Method: save(file_path, over_write)

 save(file_path, over_write) 

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

Parameters:

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

Method: save(stream)

 save(stream) 

Saves the data.

Parameters:

ParameterTypeDescription
stream_io.BufferedRandomThe stream to save data to.

Method: save(stream, options_base)

 save(stream, options_base) 

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

Parameters:

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

Method: save(stream, options_base, bounds_rectangle)

 save(stream, options_base, bounds_rectangle) 

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

Parameters:

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

Method: save_to_stream(stream)

 save_to_stream(stream) 

Saves the object’s data to the specified stream.

Parameters:

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

Method: save_to_stream_with_options(stream, options_base)

 save_to_stream_with_options(stream, options_base) 

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

Parameters:

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

Method: save_to_stream_with_options_rect(stream, options_base, bounds_rectangle)

 save_to_stream_with_options_rect(stream, options_base, bounds_rectangle) 

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

Parameters:

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

Method: save_with_options(file_path, options)

 save_with_options(file_path, options) 

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

Parameters:

ParameterTypeDescription
file_pathstringThe file path.
optionsImageOptionsBaseThe options.

Method: save_with_options_rect(file_path, options, bounds_rectangle)

 save_with_options_rect(file_path, options, bounds_rectangle) 

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

Parameters:

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

Method: set_palette(palette, update_colors)

 set_palette(palette, update_colors) 

Apply a specified palette to the image, enabling customization of color
representation. Utilize this method to enhance visual rendering and achieve
specific color effects within your application.

Parameters:

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

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

# Using Aspose.Imaging.Image.Load is a unified way to load all types of images including WMF.
with as_of(Image.load("test.wmf") as image:
	saveOptions = SvgOptions()
	# Text will be converted to shapes.
	saveOptions.text_as_shapes = True
	rasterizationOptions = WmfRasterizationOptions()
	# The background color of the drawing surface.
	rasterizationOptions.background_color = Color.white_smoke
	# The page size.
	rasterizationOptions.page_size = cast(SizeF, wmfImage.size)
	# If embedded emf exists, then render emf; otherwise render wmf.
	rasterizationOptions.render_mode = WmfRenderMode.AUTO
	saveOptions.vector_rasterization_options = rasterizationOptions
	wmfImage.save("test.output.svg", saveOptions)