Page 1 of 1

PNG ImageCopy Quality

Posted: Tue Sep 16, 2003 9:55 pm
by Pineriver
Hi, I have my background image "day.jpg" that I want to put "watermark1.png" onto. The png is 24-bit color and is the same dimension size as the JPG but has transparency in some parts.
The problem I am having is the overlay PNG image looks blury, and the background looks slightly lower in quality. Anyone know how to fix this?

Code: Select all

<?php
$im = imagecreatefromjpeg("day.jpg");

$png = imagecreatefrompng("watermark1.png");

ImageAlphaBlending($im, true);
imagecopy($im, $png, 0, 0, 0, 0, 300, 500);


ImageJPEG($im);
?>
Thanks in advance

Posted: Wed Sep 17, 2003 2:47 pm
by m3rajk
have you tried looking it up on php.net?

Posted: Thu Sep 18, 2003 12:27 am
by Pineriver
yes I have but I did not see any solution

Posted: Thu Sep 18, 2003 6:10 am
by pootergeist
maybe try imagecopymerge or imagecopyresampled to run the overlaying and make sure the jpeg is truecolour and not indexed colour.

Posted: Thu Sep 18, 2003 6:34 am
by igoy
what version of GD library u r using.....

and yeh... pootergeist is right... try imagecopyresampled().. it will give better results

Posted: Thu Sep 18, 2003 9:21 am
by pootergeist
I'd presumed above version 2 as he uses 24 bit (truecolour) PNG images and the support for PNG-24 / 32 was fixed in 2.0.0

Then version 2.0.9 fixes the glitch of copying a transparent palette based image onto a truecolour image.

You may also note that PHP4.3.2 (which runs 2.0.12 afaik) has a glitch in the imagecopymerge call wherein the last parameter became set at 100 - fixed in 2.0.15 / 4.3.3rc3 though.