首页 > 解决方案 > 如何使用 Python 实现类似深度效果的 Photoshop“斜面/浮雕”?

问题描述

我想将图像放在背景图像之上,并使用 Python 在图像上应用“斜角/浮雕”效果。我尝试使用 PIL 库,但也欢迎对其他库提出建议。

这应该是这样的:

在此处输入图像描述

我有以下代码:

from PIL import Image
from PIL import ImageFilter

img = Image.open('./image.jpeg', 'r')

# this doesn't do what I want...
img = img .filter(ImageFilter.EMBOSS)

background = Image.open('./bg.png', 'r')

background.paste(img)

我使用 Affinity Photo 作为示例图像。在Photoshop中应该几乎相同。以下是我使用的设置:

在此处输入图像描述

标签: pythonpython-imaging-libraryimage-manipulation

解决方案


我仍然不知道如何在 python 中执行此操作,但我找到了一种方法,结合使用批处理作业和 Affinity Photo 中的宏功能。

  1. 录制将所需效果应用于图像的宏
  2. 将所有需要效果的图像放在一个文件夹中
  3. 启动批处理作业并将宏应用于所有图像

此处描述了如何开始批处理作业:http: //www.millermattson.com/blog/batch-processing-with-affinity-photo/


推荐阅读