ImageMagick 对于 300 和 72 DPI 图像显示相同的打印尺寸?

问题描述 投票:0回答:1

我有两张图像,均为 2550 x 3300 像素,如果以 300 DPI 打印则为 8.5 x 11 英寸,但第一张图像为 300 DPI,而第二张图像仅为 72 DPI。

identify
命令的官方帮助页面显示了如何获取图像的打印尺寸(以英寸为单位),如果我们要以300 DPI打印图像,该命令似乎是

magick identify -format "%[fx:w/300] by %[fx:h/300] inches" document.png

但是为什么它会为两个图像返回相同的打印尺寸?

magick identify -format "%f: %wx%h pixels, %xx%y dots per inch, %[fx:w/300] by %[fx:h/300] inches at 300 DPI\n" "letter*.jpg"
letter-072-dpi.jpg: 2550x3300 pixels,  72x72  dots per inch, 8.5 by 11 inches at 300 DPI
letter-300-dpi.jpg: 2550x3300 pixels, 300x300 dots per inch, 8.5 by 11 inches at 300 DPI

我确信由于图像具有不同的 DPI,因此它们的打印尺寸也应该不同,即 300 DPI 图像为 8.5 x 11 英寸,但 72 DPI 图像则有所不同。看来我错了?

重要更新:我发现

magick identify -verbose
自动且正确地提供打印尺寸:

Print size: 8.5x11
Print size: 35.4167x45.8333

但是如何在不使用

-verbose
的情况下获得这些打印尺寸?

回复马克:

identify: Expected operand at 'x' @ error/fx.c/GetOperand/2365.
identify: Expected operand at 'x' @ error/fx.c/TranslateExpression/2664.
identify: Expected operand at 'x' @ error/fx.c/TranslateExpression/2664.
letter-072-dpi.jpg:  by 
letter-300-dpi.jpg:  by 
imagemagick dpi ppi
1个回答
0
投票

您已将 300dpi 硬编码到计算中,并忽略了实际图像中嵌入的 dpi。尝试:

magick identify -format "%f: %wx%h pixels, %xx%y dots per inch, %[fx:w/resolution.x] by %[fx:h/resolution.y] inches at embedded DPI\n" "letter*.jpg"
© www.soinside.com 2019 - 2024. All rights reserved.