note 59853 added to function.imagecreatefromgif

From: Date: Sun, 18 Dec 2005 07:35:37 +0000
Subject: note 59853 added to function.imagecreatefromgif
Groups: php.notes 
Request: Send a blank email to php-notes+get-100360@lists.php.net to get a copy of this message
this function will convert gif image to jpeg. it take three parameter as argument. two argument are optional first will take the gif file name. second for file name to save the converted file. third argument is an color array function gif2jpeg($p_fl, $p_new_fl='', $bgcolor=false){ list($wd, $ht, $tp, $at)=getimagesize($p_fl); $img_src=imagecreatefromgif($p_fl); $img_dst=imagecreatetruecolor($wd,$ht); $clr['red']=255; $clr['green']=255; $clr['blue']=255; if(is_array($bgcolor)) $clr=$bgcolor; $kek=imagecolorallocate($img_dst, $clr['red'],$clr['green'],$clr['blue']); imagefill($img_dst,0,0,$kek); imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $wd, $ht, $wd, $ht); $draw=true; if(strlen($p_new_fl)>0){ if($hnd=fopen($p_new_fl,'w')){ $draw=false; fclose($hnd); } } if(true==$draw){ header("Content-type: image/jpeg"); imagejpeg($img_dst); }else imagejpeg($img_dst, $p_new_fl); imagedestroy($img_dst); imagedestroy($img_src); } EXAMPLE: $fl='http://www.suchona.com/test/testgif.gif'; $c['red']=255; $c['green']=0; $c['blue']=0; gif2jpeg($fl, '', $c); Thanks Md. Shahadat Hossain Khan Razon razon.phpxperts.com ---- Manual Page -- http://www.php.net/manual/en/function.imagecreatefromgif.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+59853 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59853&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59853&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59853&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59853&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59853&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59853&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59853&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+59853&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#100360) next »