for($i = 1; $i<= 30000; $i ++){
$name = substr('0000' . $i, -5);
$pic = 'C' . $name . '.png';
convertDPI($pic);
}
function convertDPI($filename){
$file = file_get_contents($filename);
$len = pack("N", 9);
$sign = pack("A*", "pHYs");
$data = pack("NNC", 300 * 39.37, 300 * 39.37, 0x01);
$checksum = pack("N", crc32($sign . $data));
$phys = $len . $sign . $data . $checksum;
$pos = strpos($file, "pHYs");
if ($pos > 0) {
$file = substr_replace($file, $phys, $pos - 4, 21);
} else {
$pos = 33;
$file = substr_replace($file, $phys, $pos, 0);
}
file_put_contents('300DPI/' . $filename, $file);
}
?>