note 55391 added to function.imagecreatefromjpeg

From: Date: Tue, 02 Aug 2005 07:31:45 +0000
Subject: note 55391 added to function.imagecreatefromjpeg
Groups: php.notes 
Request: Send a blank email to php-notes+get-92930@lists.php.net to get a copy of this message
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>"; ?> ---- Manual Page -- http://www.php.net/manual/en/function.imagecreatefromjpeg.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+55391 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+55391&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+55391&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+55391&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+55391&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+55391&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+55391&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+55391&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#92930) next »