# 在 Python 中合并图像

> 在 Python 中将图像合并到图像。使用 Python 库 API 组合图像

Source: https://products.aspose.com/slides/zh/python-net/merge/image-to-image/
Updated: 2023-04-07



## 使用 Aspose.Slides 将图像合并到图像

[**Aspose.Slides for Python via .NET**](https://products.aspose.com/slides/zh/python-net/) 是一个功能强大的 Python 库，用于合并和操作演示文稿、图像和其他文件。将图像合并到图像时，实际上是将两幅图像组合成一张照片。

## 在 Python 中将图像合并到图像

Using [**Aspose.Slides for Python via .NET**](https://products.aspose.com/slides/zh/python-net/), you can merge image files quickly with just a few lines of code

### 将图像合并到图像的Python代码

```python

import aspose.slides as slides
import aspose.pydrawing as drawing

with slides.Presentation() as pres:
    slide = pres.slides[0]
    image1 = pres.images.add_image(drawing.Bitmap("image1.png"))
	slide.shapes.add_picture_frame(slides.ShapeType.RECTANGLE, 0, 0, 100, 100, image1)

    image2 = pres.images.add_image(drawing.Bitmap("image2.png"))
	slide.shapes.add_picture_frame(slides.ShapeType.RECTANGLE, 0, 200, 100, 100, image2)

    for sld in pres.slides:
        bmp = sld.get_thumbnail(1, 1)
        bmp.save("Slide_{num}.png".format(num=str(sld.slide_number)), drawing.imaging.ImageFormat.png)
```

## 如何在 Python 中合并图像

通过 .NET 安装 **Aspose.Slides for Python**。请参阅 [**安装**](https://docs.aspose.com/slides/python-net/installation/)。

将库添加为项目中的参考。

创建一个 Presentation 类的实例。

加载要合并为相框的图像。

保存生成的图像。

## 合并其他文件
