How to Check Photo DPI with PHP [duplicate]

寵の児 提交于 2019-11-28 12:24:22

It's too late for me to check now but I think you're looking for Imagick::getImageResolution() and Imagick::setImageResolution() if you need to change the DPIs.

I don't think this is possible with GD, I believe it "converts" all images to 72 DPIs.

Naeem

If you want it without Imagick or GD Library. I was struggling with this, and since I found it, here you go.

function get_dpi($filename){
    $a = fopen($filename,'r');
    $string = fread($a,20);
    fclose($a);

    $data = bin2hex(substr($string,14,4));
    $x = substr($data,0,4);
    $y = substr($data,4,4);

    return array(hexdec($x),hexdec($y));
}

and then print the array or do with it what you want.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!