Expand|Select|Wrap|Line Numbers
- <?php
- $filename = 'familyshot33.jpg';
- // open file for writing
- $f = fopen($filename, 'r+');
- $string = fread($f,20);
- // show dpi before
- echo hexdec(bin2hex(substr($string, 14, 2))) . ' ' . hexdec(bin2hex(substr($string, 16, 2))) .'<br/>';
- // update dpi
- $image = substr_replace($string, pack("Cnn", 0x01, 72, 72), 13, 5);
- // show dpi after
- echo hexdec(bin2hex(substr($image, 14, 2))) . ' ' . hexdec(bin2hex(substr($image, 16, 2))) .'<br/>';
- // write and close
- fwrite($f, $image, filesize($filename));
- fclose($f);
- ?>