我需要知道PHP中是否有可用的方法,我可以用300ppi创建图像?我看到了GD库的文档,但找不到任何信息。是否有任何方法可以处理图像并设置ppi?
或者闪存中有哪些方法可以转换图像分辨率?
由于
摩尼
答案 0 :(得分:2)
您可以使用以下示例代码:
imagejpeg($image, $file, 75);
// Change DPI
$dpi_x = 300;
$dpi_y = 300;
$image = file_get_contents($file);
// Update DPI information in the JPG header
$image[13] = chr(1);
$image[14] = chr(floor($dpi_x/255));
$image[15] = chr($dpi_x%255);
$image[16] = chr(floor($dpi_y/255));
$image[17] = chr($dpi_y%255);
// Write the new JPG
file_put_contents($file, $msg);