如何在PHP中将图像的dpi设置为300

I want to change the image DPI to 300 for existing image in PHP.

I have that image in database and i am getting it through PHP.

Code for getting image as follows:

$image = imagecreatefromstring ( base64_decode($matches[2]) );

imagepng($image, $imageFile);

I want to set DPI of above image to 300.

I am using Zend framework for it.

How can i set it using PHP?

Please help me.

I would use imagemagic to do the job

$oResamp = new Resampler;
$image = $oResamp->resample($source, $height, $width, 300);