如何使用ImageMagick查找每英寸像素数(PPI) [英] How to find pixels per inch (PPI) using ImageMagick

查看:595
本文介绍了如何使用ImageMagick查找每英寸像素数(PPI)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用以下命令获取JPEG图像的PPI:

I can get PPI for a JPEG image using the following command:

$ identify -format "%w x %h %x x %y" mypic.jpg 
1600 x 1200 72 PixelsPerInch x 72 PixelsPerInch

但是,当我在PNG格式上运行相同的命令时,我得到每厘米像素数:

However, when I run the same command on PNG format I get Pixels Per Centimeter:

$ identify -format "%w x %h %x x %y" mypic.png 
1600 x 1200 28.35 PixelsPerCentimeter x 28.35 PixelsPerCentimeter

是否有更改命令以获得PNG格式的每英寸像素数(PPI)或者根据每厘米像素计算PPI的方法?

Is there a way to change the command to get Pixels Per Inch (PPI) for PNG format as well or perhaps calculate the PPI based on the pixels per centimeter?

推荐答案

使用的分辨率和单位存储在文件中,因此如果分辨率存储在PixelsPerCentimeter中,那么标识将显示它。没有办法通过标识自动进行转换。但它只是厘米到英寸的转换数学:

The resolution and units used are stored in the file, so if the resolution is stored in PixelsPerCentimeter, that's how identify will display it. There isn't a way to do the conversion automatically through identify. But it's just cm to inch conversion math:

PixelsPerInch = PixelsPerCentimeter * 2.54

这篇关于如何使用ImageMagick查找每英寸像素数(PPI)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆