sol*_*oto 5 python jpeg resolution python-imaging-library
我正在使用 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))
Run Code Online (Sandbox Code Playgroud)
两个图像都包含相同的像素,并且在磁盘上的大小相同,但编码为不同的图像大小和分辨率。许多图像查看器都会以相同的方式显示它们,但 GiMP 和 Photoshop 等高端软件可以检测到差异。
“质量”是使用 Pillow 保存图像时的选项之一。 http://pillow.readthedocs.io/en/4.2.x/handbook/image-file-formats.html?highlight=resolution#jpeg
| 归档时间: |
|
| 查看次数: |
13866 次 |
| 最近记录: |