How to merge PNG images using Python via .NET

PNG Merger Python via .NET API

GroupDocs.Merger allows developers to combine multiple PNG documents in the preferred order and save them as a single file.

About PNG File Format

Files having extension .PNG represent Bitmap Image files that are used to store bitmap digital images. These images are independent of graphics adapter and are also called device independent bitmap (DIB) file format. This independency serves the purpose of opening the file on multiple platforms such as Microsoft Windows and Mac. The PNG file format can store data as two-dimensional digital images in both monochrome as well as color format with various colour depths.

Download and Configure

You can download GroupDocs.Merger for Python via .NET from official website Downloads section.

Source PNG images

“Sample1.png” “Sample2.png” “Sample3.png”

How to merge PNG files in vertical mode

The following example demonstrates how to merge image files in vertical mode with several lines of python-net code:

  • Create an instance of Merger class and pass source image file path as a constructor parameter. You may specify absolute or relative file path as per your requirements.
  • Create an instance of ImageJoinOptions class and pass enum value of ImageJoinMode as a constructor parameter.
  • Add another image file to merge with join method and pass instance of ImageJoinOptions class as a method parameter. Repeat this step for other image documents you want to merge.
  • Call Merger class save method and specify the filename for the merged image file as parameter.
with gm.Merger("c:/sample1.png") as merger:
    image_join_mode = gm.domain.options.ImageJoinMode.VERTICAL
    image_join_options = gm.domain.options.ImageJoinOptions(image_join_mode)
    merger.join("c:/sample2.png", join_options = image_join_options)
    merger.join("c:/sample3.png", join_options = image_join_options)
    merger.save("c:/merged.png")

Result merged PNG image

“Merged.png”

Code Examples

Please find more use-cases and complete Python via .NET sources of our backend and frontend examples and try them for free!

Merge PNG Live Demo

GroupDocs.Merger for Python via .NET provides an online PNG Merger App, which allows you to try it for free and check its quality and accuracy.