I made a function to handle jpg and png files, but i get error when trying to upload a png file.
this is the function:
function createImg ($type, $src, $
What value are you using for the quality setting? imagepng() uses values 0-9, whereas imagejpeg() uses 0-100.
Johnny Craig's answer is correct except one thing, it has inverse relationship. 9 - is the most possible compression, and 0 - no compression, so the most possible quality.
if ($type == 'png') {
$quality = round((100 - $quality) * 0.09);
}
The problem is because imagejpeg
quality can be up to 100, whereas imagepng
maximum quality is 9.
try this
else if ($type == "png") {
//imagepng() creates a PNG file from the given image.
$q=9/100;
$quality*=$q;
imagepng($newImage,$dst,$quality);
}