Online Document Merger App and Python Code to Merge PNG Files
Develop powerful Python based PNG document merging application. Combine multiple PNG documents into single one online for free via app. Save PNG file as PDF, Images, Word & many other formats online.
How to Merge PNG Files Online using App
- Upload PNG files to merge them into single one.
- Enter the parameters like selection from dropdown.
- Save to required format: Image, PDF, DOCX, HTML, and others
- Click the “Merge” button to Merge PNG into desired format.
- Download the merged PNG file.
- View and get the result of merging PNG as a single file.
How to Merge PNG File via Python
- Reference APIs within the project directly from PyPI ( Aspose.Imaging )
- Load all Images.
- Get and Set the resultant image size.
- Define the image options.
- Combine the images into new one.
- Call save method and get the merged PNG files into single file.
Code to merge PNG in Python
import aspose.pycore as aspycore | |
from aspose.imaging import Image, Rectangle, RasterImage | |
from aspose.imaging.imageoptions import JpegOptions | |
from aspose.imaging.sources import FileCreateSource | |
from aspose.imaging.fileformats.jpeg import JpegImage | |
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 | |
image_paths = [os.path.join(data_dir, "template.jpg"), | |
os.path.join(data_dir, "template.jpeg")] | |
output_path = os.path.join(data_dir, "result.jpg") | |
temp_file_path = os.path.join(data_dir, "temp.jpg") | |
# Getting resulting image size. | |
image_sizes = [] | |
for image_path in image_paths: | |
with Image.load(image_path) as image: | |
image_sizes.append(image.size) | |
new_width = 0 | |
new_height = 0 | |
for size in image_sizes: | |
new_width += size.width | |
new_height = max(new_height, size.height) | |
# Combining images into new one. | |
temp_file_source = FileCreateSource(temp_file_path, delete_output) | |
with JpegOptions() as options: | |
options.source = temp_file_source | |
options.quality = 100 | |
with aspycore.as_of(Image.create(options, new_width, new_height), JpegImage) as new_image: | |
stitched_width = 0 | |
for image_path in image_paths: | |
with aspycore.as_of(Image.load(image_path), RasterImage) as image: | |
bounds = Rectangle(stitched_width, 0, image.width, image.height) | |
new_image.save_argb_32_pixels(bounds, image.load_argb_32_pixels(image.bounds)) | |
stitched_width += image.width | |
new_image.save(output_path) | |
if delete_output: | |
os.remove(output_path) | |
if os.path.exists(temp_file_path): | |
os.remove(temp_file_path) |
import aspose.words as aw | |
fileNames = [ "sourceImage1.png", "sourceImage2.png" ] | |
doc = aw.Document() | |
builder = aw.DocumentBuilder(doc) | |
shapes = [builder.insert_image(fileName) for fileName in fileNames] | |
pageSetup = builder.page_setup | |
pageSetup.page_width = max(shape.width for shape in shapes) | |
pageSetup.page_height = sum(shape.height for shape in shapes) | |
pageSetup.top_margin = 0 | |
pageSetup.left_margin = 0 | |
pageSetup.bottom_margin = 0 | |
pageSetup.right_margin = 0 | |
doc.save("mergedImages.png") |
Develop PNG File Merger using Python
Need to develop python script or utility app to easily merge multiple PNG files? With Aspose.Imaging for Python via .NET, child API of Aspose.Total for Python via .NET, any python developer can integrate the above API code to concatenate documents easily for developing professional solution. Powerful Python library for merging documents supports many popular formats including PNG format.
PNG merging library for Python
There are alternative options to install ‘Aspose.Imaging for Python via .NET’ or ‘Aspose.Total for Python via .NET’ onto your system. Please choose one that resembles your needs and follow the step-by-step instructions:
- Install Aspose.Imaging for Python via .NET from PyPI
- Or Use the following pip commands
pip install aspose-imaging-python-net
.
System Requirements
- GNU libc >= 2.17
- GCC-6 runtime libraries (or later).
- For Python 3.5-3.7: The pymalloc build of Python is needed.
Fore more details please refer to Product Documentation .
FAQs
- Can I use above Python code in my application?Yes, you are welcome to download this code and utilize it for the purpose of developing Python-based applications focused on combining PNG documents. One can develop professional solution to combine PNG using Python. Use our PNG merging API to develop high-level, platform independent software in Python.
- Is this document merging App work only on Windows?You have the flexibility to initiate document merging from any device, irrespective of the operating system it runs on, whether it be Windows, Linux, Mac OS, or Android. All that's required is a contemporary web browser and an active internet connection.
- Is it safe to use the online app to combine multiple PNG documents?Of course! The output files generated through our service will be securely and automatically removed from our servers within a 24-hour timeframe. As a result, the download links associated with these files will cease to be functional after this period.
- What browser should to use App?You can use any modern web browser like Google Chrome, Firefox, Opera, or Safari for online PNG document merging.
- How can I merge multiple PNG files?Start by uploading one or more files you want to merge. You can either drag and drop your PNG files or simply click inside the white area. Afterward, click the 'Merge' button, and our merger will quickly process the uploaded files.
- How long does it take to merge the PNG files?This merging application operates quickly, It may take a few seconds to upload the files and merge them.