duansha8764 2016-07-26 04:52
浏览 668

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

I'm creating php image by tile small image over certain width and height. In this output image dpi is 72 by default. But I need to change it to 300. Changing exif data is enough. But I cannot use Imagick for this. Anyone can help?

$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条回答 默认 最新

  • douyan1613 2018-04-19 06:15
    关注

    Try this

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

    But just note that it will for JPG images and converting an image from 72 to 300 is really a bad idea. And may I know why you need 300 DPI image for ?

    评论

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)