PNG ImageCopy Quality

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Pineriver
Forum Commoner
Posts: 50
Joined: Fri Aug 15, 2003 5:24 pm

PNG ImageCopy Quality

Post 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
m3rajk
DevNet Resident
Posts: 1191
Joined: Mon Jun 02, 2003 3:37 pm

Post by m3rajk »

have you tried looking it up on php.net?
Pineriver
Forum Commoner
Posts: 50
Joined: Fri Aug 15, 2003 5:24 pm

Post by Pineriver »

yes I have but I did not see any solution
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

maybe try imagecopymerge or imagecopyresampled to run the overlaying and make sure the jpeg is truecolour and not indexed colour.
User avatar
igoy
Forum Contributor
Posts: 203
Joined: Fri May 02, 2003 11:57 pm
Location: India
Contact:

Post by igoy »

what version of GD library u r using.....

and yeh... pootergeist is right... try imagecopyresampled().. it will give better results
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post 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.
Post Reply