after uploading an image I place it in a folder using
documentation says that this function resamples the image to a given quality, depending on third param in the function:
imagejpeg($newimg, $path, 80);
problem – whatever value I set as quality (50 – 70 – 99 …) the resulting image is always
so how to get an image having
72 dpi ?
DPI and quality are two completely different things.
The DPI is a piece of metadata that tells software how to scale the number of pixels in the image into inches. (This is generally only used when printing onto paper and in image editing software such as Photoshop; rendering the image on a website will work in pixels not inches).
The quality determines how much compression to use.
imageresolution function lets you adjust the DPI metadata.
This comment, on the page you linked to, explains how to adjust the DPI setting manually.
<?php imagejpeg($image, $file, 75); // Change DPI $dpi_x = 150; $dpi_y = 150; // Read the file $size = filesize($file); $image = file_get_contents($file); // Update DPI information in the JPG header $image = chr(1); $image = chr(floor($dpi_x/256)); $image = chr( $dpi_x%256); $image = chr(floor($dpi_y/256)); $image = chr( $dpi_y%256); // Write the new JPG $f = fopen($file, 'w'); fwrite($f, $msg, $size); fclose($f); ?>