【问题标题】:php change image resolution(dpi) without imagickphp在没有imagick的情况下更改图像分辨率(dpi)
【发布时间】:2018-04-19 14:15:02
【问题描述】:

我正在通过在一定宽度和高度上平铺小图像来创建 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);

【问题讨论】:

    标签: php


    【解决方案1】:

    试试这个

     $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 图像吗?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-11-04
      相关资源
      最近更新 更多