gpt4 book ai didi

python - Wand 未正确设置 Jpeg 图像分辨率

转载 作者:行者123 更新时间:2023-12-01 09:15:47 25 4
gpt4 key购买 nike

我正在尝试调整 jpeg 图像的大小并放大框架。为此,我对原始图像应用了调整大小,并将其合成在新图像上:

with Image(blob=binary_data) as img:
...
img.resize(width=new_width, height=long(2000))
# Compose image to enlarge frame
with Image(width=1571, height=2000, background=Color('white')) as dst_image:
...
dst_image.composite(img, x, 0)
img = dst_image
img.resolution = (300,300)
img.format = 'jpg'
jpeg_bin = img.make_blob()

最终我期望分辨率为 300dpi。 Imagemagick命令“identify”显示分辨率为300dpi,但事实并非如此;确实,如果我打开它使用 Gimp 它显示的分辨率为 72dpi。

我正在使用 Wand v.0.4.4。

我的代码有问题吗? ...有什么想法吗?

最佳答案

@fmw42:谢谢,这是单位定义的问题。在修复之前,这是 exiftools 的输出:

  Resolution Unit                 : None
X Resolution : 300
Y Resolution : 300

我通过插入这一行修复了它:

  dst_image.units = 'pixelsperinch'

现在 exiftools 和 gimp 返回相同的分辨率:

  Resolution Unit                 : inches
X Resolution : 300
Y Resolution : 300

谢谢!

关于python - Wand 未正确设置 Jpeg 图像分辨率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51271878/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com