php - losing quality and size , after adding watermark to image -
i'm working on website didn't create/develop.
users can upload image , when that, there's function creates duplicate of image watermark.
but copy watermark of low quality , size smaller original image
function watermark( $path ){ $watermark = imagecreatefrompng('files/watermark.png'); $wmsize = getimagesize('files/watermark.png'); $image = imagecreatefromjpeg($path); $size = getimagesize($path); $dest_x = (8); $dest_y = ($size[1] - 35 ); imagecopy($image, $watermark, $dest_x, $dest_y, 0, 0, $wmsize[0], $wmsize[1]); ob_start(); imagejpeg($image); $img2 = ob_get_contents(); ob_end_clean(); imagedestroy($image); return $img2 ; }
the image quality decreased because of jpeg compression.
every time save image jpeg decrease quality because jpeg uses lossy compression. can minimize loss setting compress quality 100%, if perform lossless compression not possible jpeg , must image format, e.g. tiff.
Comments
Post a Comment