A
Anonymous
Guest
If you want 300dpi then you need 300 pixels per inch.
So
One thing to note this code does not scale the image and add borders.
It only resizes by stretching.
So
Code:
<?php
function resizeimage( $filename, $savename, $width, $height, $dpi )
{
$size_w = $width*$dpi;
$size_h = $height*$dpi;
$image = imagecreatetruecolor( $size_w, $size_h );
$info = getimagesize( $filename );
$import = imagecreatefromjpeg( $filename );
imagecopyresampled( $image, $import, 0, 0, 0, 0, $size_w, $size_h, $info[0], $info[1] );
imagepng( $image, $savename, 0 );
imagedestroy( $image );
}
// Set the dpi
$dpi = 300;
// 24" x 18"
$width = 24; // In Inches
$height = 18; // In Inches
resizeimage( $filename, $savename, $width, $height, $dpi );
?>
One thing to note this code does not scale the image and add borders.
It only resizes by stretching.