php改变图像分辨率(dpi)没有想象力

时间:2016-07-26 04:52:23

标签: php

我通过在一定宽度和高度上平铺小图像来创建php图像。在此输出图像中,dpi默认为72。但我需要将其更改为300.更改exif数据就足够了。但我不能使用Imagick。有人可以帮忙吗?

$size = getimagesize($mask);
//Resize to this size
$width = $size[0];
$height = $size[1];

$im = imagecreatetruecolor($width, $height);

// Set the tile
imagesettile($im, $pattern_sys);

// Make the image repeat
imagefilledrectangle($im, 0, 0, $width, $height, IMG_COLOR_TILED);       

// Output image with resized        
$mask_sys = imagecreatefrompng($mask);
//$mask_new = imagecreate($width ,$height);

imagepng($im, $print_path);

imagecopy( $im , $mask_sys , 0 , 0 , 0 , 0 , $width , $height);

imagepng($im,$design_path);

1 个答案:

答案 0 :(得分:0)

试试这个

 $imageGet = file_get_contents($imagePath);
 if($imageGet){
    $imageConverted = substr_replace($imageGet, pack("cnn", 1, 300, 300), 13, 5);
    $savefile = file_put_contents($newImagePath, $imageConverted);
  }

但请注意,它将用于JPG图像并将图像从72转换为300真的是一个坏主意。我可以知道为什么你需要300 DPI图像吗?

相关问题