我正在使用Python Pillow修改图片。每当我保存jpeg格式的图片时,内部分辨率会被设置为72dpi。我想知道如何将其设置为不同的值。我意识到这只是一个数字,在很多方面都是无意义的。我的动机是在将图片读入Photoshop时,使后续工作更加容易。
我正在使用Python Pillow修改图片。每当我保存jpeg格式的图片时,内部分辨率会被设置为72dpi。我想知道如何将其设置为不同的值。我意识到这只是一个数字,在很多方面都是无意义的。我的动机是在将图片读入Photoshop时,使后续工作更加容易。
我想你可能在寻找dpi(每英寸点数)相关的内容。
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))
两幅图像包含相同的像素,并且在磁盘上的大小也相同,但它们被编码为不同的图像尺寸和分辨率。许多图像查看器会以相同的方式显示它们,但高端软件如The GiMP和Photoshop可以检测到差异。
'quality' 是使用 Pillow 保存图像时的选项之一。 http://pillow.readthedocs.io/en/4.2.x/handbook/image-file-formats.html?highlight=resolution#jpeg