note 83347 deleted from function.imagejpeg by cmb
| From: | cmb@php.net | Date: | Sun, 20 Oct 2019 08:59:30 +0000 |
| Subject: | note 83347 deleted from function.imagejpeg by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-212722@lists.php.net to get a copy of this message | ||
Note Submitter: xavi at lapalomera dot com
----
For those whom needs other dpi image than the GD library, just do the following:
<?php
//Get jpeg image contents
ob_start();
imagejpeg($image, "", 100);
$image = ob_get_contents();
ob_end_clean();
//Or read jpeg image
$image = file_get_contents($file);
//Replace header image info to set DPI as units and the density for X and Y
//First parameter are units for X and Y densities (0x00 No units, 0x01 DPI, 0x02 DPC)
//Second parameter is the X density
//Third parameter is the Y density
$image = substr_replace($image, pack("Cnn", 0x01, 300, 300), 13, 5);
header("Content-type: image/jpeg");
header('Content-Disposition: attachment;
filename="'.basename($file).'"');
echo $image;
?>