Merge Images in Python
Combine multiple images into one PNG file with a cross-platform Python API
Merge Images Using Aspose.Slides
Aspose.Slides for Python via .NET
lets you place multiple images on one Slide and render the combined layout as a single image. Load each source image with Images.from_file, add it to Presentation.images, create picture frames, and save the rendered IImage with ImageFormat.PNG.
Merge Images into One PNG File in Python
Create a Presentation, place the source images side by side on its first Slide, and render the slide as one PNG file.
Python code for merging images into one PNG file
with slides.Presentation() as presentation:
slide = presentation.slides[0]
with slides.Images.from_file("image1.png") as first_source_image:
first_presentation_image = presentation.images.add_image(first_source_image)
slide.shapes.add_picture_frame(
slides.ShapeType.RECTANGLE, 0, 0, 360, 270, first_presentation_image)
with slides.Images.from_file("image2.png") as second_source_image:
second_presentation_image = presentation.images.add_image(second_source_image)
slide.shapes.add_picture_frame(
slides.ShapeType.RECTANGLE, 360, 0, 360, 270, second_presentation_image)
with slide.get_image(1, 1) as combined_image:
combined_image.save("merged.png", slides.ImageFormat.PNG)
How to Merge Images in Python
Follow these steps to combine multiple images into one PNG file.
Install Aspose.Slides for Python via .NET .
Import the
aspose.slidesmodule in your Python project.Create a
Presentationand access its firstSlide.Load the source images with
Images.from_file, add them toPresentation.images, and arrange them in picture frames.Render the
SlidewithSlide.get_image, then callIImage.savewithImageFormat.PNG.
Merge Other Files
You can also combine files in other formats.