我正在使用 Python Pillow 来修改图像。每当我保存 jpeg 时,内部分辨率都会设置为 72dpi。我想看看如何将其设置为不同的值。我意识到这只是一个数字,在很多方面它毫无意义。我的动机是当我将图像读入 Photoshop 时使后续工作变得更容易。
我想你可能正在寻找dpi https://pillow.readthedocs.io/en/stable/handbook/image-file-formats.html.
from PIL import Image, ImageDraw
# Make a white background with a blue circle, just for demonstration
im = Image.new('RGB', (800, 600), (255, 255, 255))
draw = ImageDraw.Draw(im)
draw.ellipse((200, 100, 600, 500), (32, 32, 192))
# the default
im.save("image_72.jpeg")
# explicit dpi for high resolution uses like publishing
im.save("image_300.jpeg", dpi=(300, 300))
两个图像都包含相同的像素,并且在磁盘上的大小相同,但编码为不同的图像大小和分辨率。许多图像查看器都会以相同的方式显示它们,但 GiMP 和 Photoshop 等高端软件可以检测到差异。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)