Zend - The PHP Company




Graphics

Add Code


GIF2PNG  

Type: code fragment
Added by: tcr480
Entered: 08/10/2002
Last modified: 31/10/2001
Rating: - (fewer than 3 votes)
Views: 4416
Well, I was shifting from GD with GIF to a newer without GIF, but I had one problem. I had to convert about 2000 GIF files into PNG... that was bad. So I did a little code, that did the work for me. It can easily be rewritten so it also can handle etc. JPEG.


<?php
//GIF2PNG
$ConvertFromDir ''//Directory where files that have to be coverted is placed!
$ConvertToDir ''//Directory where the converted files have to be placed!
$fp popen('/bin/sh''w');
if(
$dir = @opendir($ConvertFromDir)) {
    while((
$file readdir($dir))!==false) {
        
fputs($fp'/usr/bin/convert '.$ConvertFromDir.$file.' '.$ConvertToDir.substr($file0, -3).'png'."n");
    }
    
closedir($dir);
}
pclose($fp);
?>


Usage Example




Rate This Script





Search



This Category All Categories