Use Python for WMF Images Merge
Create Python Apps to Merge WMF Images and Photos via Server APIs
How to Merge WMF Images and Photos with Python
Utilizing the collage technique empowers you to craft a captivating composition from a collection of pre-existing images and photos. The Python library provides the functionality to merge images and photos seamlessly, regardless of variations in their source file formats. An effective strategy to highlight your portfolio involves employing wallpapers ornament with recurring images or patterns, allowing for both horizontal and vertical arrangements. Should your objective be showcasing the outcome of file processing, seamlessly merging two images — before and after applying the image effect — is a straightforward task. To merge WMF images, we will employ Aspose.Imaging for Python via .NET API which is a feature-rich, powerful and easy to use image manipulation and conversion API for Python platform. You may install it using the following command from your system command.
The system command line
>> pip install aspose-imaging-python-net
Steps to Merge WMF via Python
You need the aspose-imaging-python-net to try the following workflow in your own environment.
- load WMF files with Image.Load method;
- combining images into new one;
- save merged image to disc in the supported by Aspose.Imaging format.
System Requirements
Aspose.Imaging for Python is supported on all major operating systems. Just make sure that you have the following prerequisites.
- Microsoft Windows / Linux with .NET Core Runtime.
- Python and PyPi package manager.
Merge WMF images - Python
from aspose.imaging import RasterImage, Image | |
from aspose.imaging.fileformats.tiff import TiffImage, TiffFrame | |
from aspose.imaging.fileformats.tiff.enums import TiffExpectedFormat | |
from aspose.imaging.imageoptions import TiffOptions, PdfOptions, PngOptions | |
from aspose.pycore import as_of | |
import os | |
if 'TEMPLATE_DIR' in os.environ: | |
templates_folder = os.environ['TEMPLATE_DIR'] | |
else: | |
templates_folder = r"C:\Users\USER\Downloads\templates" | |
delete_output = 'SAVE_OUTPUT' not in os.environ | |
data_dir = templates_folder | |
images = {} | |
files = ["template.emf", "template.wmf"] | |
max_width = 0 | |
max_height = 0 | |
i = 0 | |
for file_name in files: | |
with Image.load(os.path.join(data_dir, file_name)) as image: | |
output_file_name = os.path.join(data_dir, f"{file_name}{i}.png") | |
i += 1 | |
image.save(output_file_name, PngOptions()) | |
raster_image = Image.load(output_file_name) | |
if raster_image.width > max_width: | |
max_width = raster_image.width | |
if raster_image.height > max_height: | |
max_height = raster_image.height | |
images[output_file_name] = raster_image | |
output_path1 = os.path.join(data_dir, "multiframe.tiff") | |
output_path2 = os.path.join(data_dir, "multipage.pdf") | |
frame1 = next(iter(images.values())) | |
with TiffImage(TiffFrame(as_of(frame1, RasterImage))) as tiff_image: | |
# for loop | |
for path, page in images.items(): | |
if page != frame1: | |
tiff_image.add_page(as_of(page, RasterImage)) | |
tiff_image.save(output_path1, TiffOptions(TiffExpectedFormat.TIFF_JPEG_RGB)) | |
tiff_image.save(output_path2, PdfOptions()) | |
for path, image in images.items(): | |
# to dispose the image we call __exit__() | |
with image as _: | |
pass | |
if delete_output: | |
os.remove(path) | |
if delete_output: | |
os.remove(output_path1) | |
os.remove(output_path2) |
About Aspose.Imaging for Python API
Aspose.Imaging API is an image processing solution to create, modify, draw or convert images (photos) within applications. It offers: cross-platform Image processing, including but not limited to conversions between various image formats (including uniform multi-page or multi-frame image processing), modifications such as drawing, working with graphic primitives, transformations (resize, crop, flip&rotate, binarization, grayscale, adjust), advanced image manipulation features (filtering, dithering, masking, deskewing), and memory optimization strategies. It’s a standalone library and does not depend on any software for image operations. One can easily add high-performance image conversion features with native APIs within projects. These are 100% private on-premise APIs and images are processed at your servers.Merge WMF via Online App
Merge WMF documents by visiting our Live Demos website The live demo has the following benefits
WMF What is WMF File Format
Files with WMF extension represent Microsoft Windows Metafile (WMF) for storing vector as well as bitmap-format images data. To be more accurate, WMF belongs to the vector file format category of Graphics file formats that is device independent. Windows Graphical Device Interface (GDI) uses the functions stored in a WMF file to display an image on the screen. A more enhanced version of WMF, known as Enhanced Meta Files (EMF), was published later that makes the format more feature rich. Practically, WMF are similar to SVG.
Read MoreOther Supported Merge Formats
Using Python, one can easily merge different formats including: