I need to Convert GIF to PNG in realtime

hknight

Joined: 2003-08-21
Posts: 7
Posted: Mon, 2004-01-19 20:42

I am looking for a script that will convert a gif picture to png format in realtime.

So that convert.php?picture.gif.jpg or whatever returns a png of the original image picture.gif.

I need it to work with PHP in a Linux enviroment. I have the Gallery NETPBM binaries installed and would like to use NETPBM if possible.

Any ideas?

Thanks,
Hank[/b]

 
alindeman
alindeman's picture

Joined: 2002-10-06
Posts: 8194
Posted: Mon, 2004-01-19 21:28

Sure, here goes:

<?php
$netpbmPath = "/fill/this/in/with/the/netpbm/path"; //don't put a slash on the end

header ("Content-Type: image/png");

$file = $_SERVER['QUERY_STRING'];
echo `$netpbmPath/giftopnm $file | $netpbmPath/pnmtopng`;
?>

That should work. Post back if it doesn't.

 
hknight

Joined: 2003-08-21
Posts: 7
Posted: Tue, 2004-01-20 16:21

Thanks! It works great.

 
alindeman
alindeman's picture

Joined: 2002-10-06
Posts: 8194
Posted: Tue, 2004-01-20 21:50

No problema :)