By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,070 Members | 1,718 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,070 IT Pros & Developers. It's quick & easy.

is it possible to convert image types (GD2)

P: n/a
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif,
png) into another type? Especially, I know I can read a gif with GD2, but I
really need to be able to save it as a png. Is that possible?

-dg
Jul 17 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
dan glenn schrieb:
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif,
png) into another type? Especially, I know I can read a gif with GD2, but I
really need to be able to save it as a png. Is that possible?


Why don't you just have a look at the documentation?

http://www.php.net/manual/en/function.imagepng.php

Regards,
Matthias
Jul 17 '05 #2

P: n/a
On Sat, 19 Jun 2004 07:13:48 GMT, "dan glenn" <da********@yahoo.com> wrote:
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif,
png) into another type? Especially, I know I can read a gif with GD2, but I
really need to be able to save it as a png. Is that possible?


Yes, it is.

--
Andy Hassall <an**@andyh.co.uk> / Space: disk usage analysis tool
http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space
Jul 17 '05 #3

P: n/a
"dan glenn" <da********@yahoo.com> wrote in message
news:MI*******************@newssvr29.news.prodigy. com...
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif,
png) into another type? Especially, I know I can read a gif with GD2, but I really need to be able to save it as a png. Is that possible?


You can convert gif into png or jpeg but no vice-versa. The imagepng() and
impagejpeg() will save the image into the respected format.
Jul 17 '05 #4

P: n/a

"Chung Leong" <ch***********@hotmail.com> wrote in message
news:xc********************@comcast.com...
"dan glenn" <da********@yahoo.com> wrote in message
news:MI*******************@newssvr29.news.prodigy. com...
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif, png) into another type? Especially, I know I can read a gif with GD2,
but I
really need to be able to save it as a png. Is that possible?


You can convert gif into png or jpeg but no vice-versa. The imagepng() and
impagejpeg() will save the image into the respected format.


OK - I'm now saving .gif's to .png's, but I note that I lose the
transparancy (if there is one) in doing so. How can I maintain the
transparancy in the PNG???

-dg
Jul 17 '05 #5

P: n/a
"dan glenn" <da********@yahoo.com> wrote in message
news:UF*******************@newssvr29.news.prodigy. com...

"Chung Leong" <ch***********@hotmail.com> wrote in message
news:xc********************@comcast.com...
"dan glenn" <da********@yahoo.com> wrote in message
news:MI*******************@newssvr29.news.prodigy. com...
(PHP4.3.4) Is it possible to change an image that's in one type (jpg, gif, png) into another type? Especially, I know I can read a gif with GD2, but
I
really need to be able to save it as a png. Is that possible?


You can convert gif into png or jpeg but no vice-versa. The imagepng()

and impagejpeg() will save the image into the respected format.


OK - I'm now saving .gif's to .png's, but I note that I lose the
transparancy (if there is one) in doing so. How can I maintain the
transparancy in the PNG???


Hmmm, I just tried it and it works correctly. I'm using 4.3.6. Maybe GD is
saving the PNG with alpha-channel info (which IE doesn't support) instead of
single color transparency. View the image in Netscape or open it with
Photoshop and see if transparency is there.
Jul 17 '05 #6

P: n/a

"Chung Leong" <ch***********@hotmail.com> wrote in message
news:ie********************@comcast.com...
"dan glenn" <da********@yahoo.com> wrote in message
news:UF*******************@newssvr29.news.prodigy. com...

"Chung Leong" <ch***********@hotmail.com> wrote in message
news:xc********************@comcast.com...
"dan glenn" <da********@yahoo.com> wrote in message
news:MI*******************@newssvr29.news.prodigy. com...
> (PHP4.3.4) Is it possible to change an image that's in one type
(jpg,
gif,
> png) into another type? Especially, I know I can read a gif with
GD2, but
I
> really need to be able to save it as a png. Is that possible?
>

You can convert gif into png or jpeg but no vice-versa. The imagepng()
and impagejpeg() will save the image into the respected format.


OK - I'm now saving .gif's to .png's, but I note that I lose the
transparancy (if there is one) in doing so. How can I maintain the
transparancy in the PNG???


Hmmm, I just tried it and it works correctly. I'm using 4.3.6. Maybe GD is
saving the PNG with alpha-channel info (which IE doesn't support) instead

of single color transparency. View the image in Netscape or open it with
Photoshop and see if transparency is there.


Yes, you're right - the transparency is there. It was just IE. Gad. OK - is
there a way I can make imagepng() save the PNG as a palette-based (8-bit,
256-color) single-color transparancy? (These will work in IE, as they don't
use the alpha channel)
Jul 17 '05 #7

P: n/a
"dan glenn" <da********@yahoo.com> wrote in message news:<RF****************@newssvr25.news.prodigy.co m>...
<snip
Hmmm, I just tried it and it works correctly. I'm using 4.3.6. Maybe GD is
saving the PNG with alpha-channel info (which IE doesn't support) instead

of
single color transparency. View the image in Netscape or open it with
Photoshop and see if transparency is there.


Yes, you're right - the transparency is there. It was just IE. Gad. OK - is
there a way I can make imagepng() save the PNG as a palette-based (8-bit,
256-color) single-color transparancy? (These will work in IE, as they don't
use the alpha channel)


You may be interested in phpSt.Justin's wonderful article on the
subject <http://www.koivi.com/ie-png-transparency/>

--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
Jul 17 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.