Page 1 of 1

Using PNG-24 in PHP GD

Posted: Mon Jun 22, 2009 1:51 am
by unknown365
Hi Everyone!
I want to use PNG-24 in GD so that I would get a better image quality.
My problem is that whenever I use PNG-24, the image that i try to call using "imagecreatefrompng" becomes a different image. Also, the image that I use has a transparent background but whenever I use the PNG-24 image, the background becomes white.

However in using a PNG-8 image, I don't encounter these two problems.

Below are the images that I used
PNG-8 (the original look of the image)
Image

PNG-24
Image

As can be seen above, the PNG-24 is totally different from the PNG-8. Please help!

Re: Using PNG-24 in PHP GD

Posted: Mon Jun 22, 2009 8:37 am
by unknown365
Can anyone please help me? :(

Re: Using PNG-24 in PHP GD

Posted: Mon Jun 22, 2009 10:12 am
by onion2k
My problem is that whenever I use PNG-24, the image that i try to call using "imagecreatefrompng" becomes a different image.
What do you mean by "becomes a different image"?

I imagine it'll be due to PNG-24 not having any transparency support (use PNG-32 for an alpha channel), but that's just a guess.

Re: Using PNG-24 in PHP GD

Posted: Mon Jun 22, 2009 8:46 pm
by unknown365
The output picture of the PNG-8 and PNG-24 is posted above

Re: Using PNG-24 in PHP GD

Posted: Tue Jun 23, 2009 12:17 am
by McInfo
May I see some PHP code?

Edit: This post was recovered from search engine cache.

Re: Using PNG-24 in PHP GD

Posted: Tue Jun 23, 2009 1:36 am
by unknown365
I was already able to solve the problem but I was just wondering...does the quality of an image changes if I use GD? Because in my case, the quality of the image i used in GD suddenly had some edges. Is this normal?

Re: Using PNG-24 in PHP GD

Posted: Tue Jun 23, 2009 3:16 am
by onion2k
unknown365 wrote:I was already able to solve the problem but I was just wondering...does the quality of an image changes if I use GD? Because in my case, the quality of the image i used in GD suddenly had some edges. Is this normal?
It will depend on your code, not GD. I imagine you're inputting a PNG-32 (or PNG-24) image, and outputting a PNG-8 image. That will end up doing nasty things because you're going from true colour to a colour palette.

Re: Using PNG-24 in PHP GD

Posted: Tue Jun 23, 2009 10:09 am
by McInfo
For smooth edges, use imagesavealpha().

Related topic: 101361

Edit: This post was recovered from search engine cache.