如何在PHP中获取Image DPI [英] How to get Image DPI in PHP

查看:146
本文介绍了如何在PHP中获取Image DPI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找可以帮助我在PHP中获取图像DPI的代码。

I am searching for the code which could help me to get the Image DPI in PHP.

任何人都可以看一下吗?

Could any one look into this ?

提前致谢。

推荐答案

您可以为此寻找一些图像库。例如:Imagick,GD Library ...

You can go for some image libraries for that. Eg: Imagick, GD Library...

(OR)

您可以使用以下功能,

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,0,4);

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

这里已经解决了这个问题...... :)

这篇关于如何在PHP中获取Image DPI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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