note 55391 deleted from function.imagecreatefromjpeg by cmb

From: Date: Sun, 11 Dec 2016 11:08:07 +0000
Subject: note 55391 deleted from function.imagecreatefromjpeg by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-208492@lists.php.net to get a copy of this message
Note Submitter: elyoukey at hotmail dot com ---- here is a code, inspired by the button of tl at comvironment dot com but here, you can make as many buttons as you need by cutting the image in as many parts as defined in the table <?php class Button_Array{ var $tab_button = array();// the text of each button you want to create var $im;//the image file function Button_Array($fileName, $tab_string){ $this -> tab_button = $tab_string; $this -> im = $fileName; //parameters $font = 10; //cut the full image in X parts //X = the number of buttons you want $imgFull=ImageCreateFromJPEG($this -> im); list($width, $heightFull, $type, $attr) = getimagesize($this -> im); $height = round($heightFull/sizeof($this->tab_button),0); for ($i=0;$i<sizeof($this->tab_button);$i++ ) { $pos=$i*$height; $imgParts[$i]=ImageCreateTrueColor($width,$height); if(imagecopy($imgParts[$i],$imgFull,0,0,0,$pos,$width,$height)){ //manips $textColor = imagecolorallocate ($imgParts[$i],0,20,90); ImageString ($imgParts[$i],$font,200,10,$this->tab_button[$i],$textColor); //création du fichier ImageJPEG($imgParts[$i] , $this->tab_button[$i].'.jpg',85); } } } } $tab[]="topic1"; $tab[]="topic2"; $tab[]="topic3"; $tab[]="topic4"; $tab[]="more topics"; $tabButton=new Button_Array("a.jpg",$tab); echo "<table border=0 cellspacing=0 cellpadding=0>"; foreach ($tab as $source) { echo "<tr><td><img src='$source.jpg'></td></tr>"; } echo "</table>"; ?>

« previous php.notes (#208492) next »