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);
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 ?