how can i change the dpi of an image with the imagick extension

后端 未结 2 1629
刺人心
刺人心 2020-12-18 03:07

I need to change all uploaded files to 72 dpi. I\'m using the php imagick extension.

heres what i\'ve tried (the image i\'m using is 300dpi):

$image          


        
2条回答
  •  再見小時候
    2020-12-18 03:22

    MatTheCat's answer is spot on. You might also try setImageUnits() to ensure it's working with inches and not centimeters.

    $image->setImageUnits(imagick::RESOLUTION_PIXELSPERINCH);
    $image->setImageResolution(72,72);
    

    Resampling isn't necessary just to change dpi.

    Note that changing the dpi alone will not affect file size and only applies to resampling and printing.

提交回复
热议问题