How to create 300ppi image in php?
-
22-12-2020 - |
Question
I need to know is there any method available in PHP through which I can create images in 300ppi? I saw the documentation of GD library but can't found any info. Is there any method through with I can process image and set the ppi?
Alternatively is there any method available in flash that convert the image resolution?
Thanks
Mani
Solution
Here a sample code you can use:
imagejpeg($image, $file, 75);
// Change DPI
$dpi_x = 300;
$dpi_y = 300;
$image = file_get_contents($file);
// Update DPI information in the JPG header
$image[13] = chr(1);
$image[14] = chr(floor($dpi_x/255));
$image[15] = chr($dpi_x%255);
$image[16] = chr(floor($dpi_y/255));
$image[17] = chr($dpi_y%255);
// Write the new JPG
file_put_contents($file, $msg);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow