Hi to get the dpi of any image you can use the following code
php opening tag
function get_dpi($filename){
// open the file and read first 20 bytes.
$a = fopen($filename,’r');
$string = fread($a,20);
fclose($a);
// get the value of byte 14th up to 18th
$data = bin2hex(substr($string,14,4));
$x = substr($data,0,4);
$y = substr($data,4,4);
return array(hexdec($x),hexdec($y));
}
// sample, output the result:
print_r(get_dpi(‘demo_files/abc.png’));
php close tag
I test it and my result are bad :(
ReplyDeleteget_dpi($filename)
16172630_1.jpg ---> 1 1
AldoFigeroa.jpg ---> 10752 10752
carnet_raul.jpg ---> 300 300
$image=new Imagick($tmp_file);
16172630_1.jpg ---> 72 72
AldoFigeroa.jpg ---> 200 200
carnet_raul.jpg ---> 300 300
testeando los resultados obtenidos son diferentes en algunos casos iguales alguien que me diga por que?