Re: PHP4+IIS4+NT+GD

From: Date: Wed, 11 Oct 2000 12:21:11 +0000
Subject: Re: PHP4+IIS4+NT+GD
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-2312@lists.php.net to get a copy of this message
Acabo de probar el ejemplo que has mandado y me da este error: <b>Warning</b>: imagecreatefrompng: Unable to open 'table_header.png' for reading in <b>c:/inetpub/wwwroot/php/_david/graph/b.php</b> on line <b>64</b><br> De todas maneras la version de GD que tengo si que soporta GIF, la he bajado hoy mismo... David Ayala Villuendas david@preus.scs.es Unitat d´Informàtica DAP Reus-Altebrat udi@preus.scs.es > Hola, > > Si no me equivoco, a mi me paso lo mismo. La version de GD que usas no tiene > apoyo para los GIFs, tienes que usar JPEGs o PNGs. El codigo que bajaste de > ejemplo esta usando las funciones de GIFs, jamas te funcionara. Tienes que > usar un ejemplo que use JPEGs o PNGs, yo tengo tal ejemplo (text_png.php): > > [Observa bien la variable $font, es posible que tengas que jugar un poco con > esto para que te funcione a ti (Yo uso Apache)] > > > <? > /* > To draw the PNG - call this script with a URL like the following: > http://www.yoursite.com/text_png.php?size=14&msg=Mensaje > */ > Header( "Content-type: image/png"); > > class textPNG { > var $font = "C:/Windows/Fonts/Arialbd.ttf"; //default font. directory > relative to script directory. > var $msg = "test"; // default text to display. > var $size = 24; > var $rot = 0; // rotation in degrees. > var $pad = 0; // padding. > var $transparent = 1; // transparency set to on. > var $red = 0; // white text... > var $grn = 0; > var $blu = 0; > var $bg_red = 255; // on black background. > var $bg_grn = 255; > var $bg_blu = 255; > > function draw() { > $width = 0; > $height = 0; > $offset_x = 0; > $offset_y = 0; > $bounds = array(); > $image = ""; > > // determine font height. > $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, "W"); > if ($this->rot < 0) { > $font_height = abs($bounds[7]-$bounds[1]); > } else if ($this->rot > 0) { > $font_height = abs($bounds[1]-$bounds[7]); > } else { > $font_height = abs($bounds[7]-$bounds[1]); > } > > // determine bounding box. > $bounds = ImageTTFBBox($this->size, $this->rot, $this->font, > $this->msg); > if ($this->rot < 0) { > $width = abs($bounds[4]-$bounds[0]); > $height = abs($bounds[3]-$bounds[7]); > $offset_y = $font_height; > $offset_x = 0; > > } else if ($this->rot > 0) { > $width = abs($bounds[2]-$bounds[6]); > $height = abs($bounds[1]-$bounds[5]); > $offset_y = abs($bounds[7]-$bounds[5])+$font_height; > $offset_x = abs($bounds[0]-$bounds[6]); > > } else { > $width = abs($bounds[4]-$bounds[6]); > $height = abs($bounds[7]-$bounds[1]); > $offset_y = $font_height;; > $offset_x = 0; > } > > // $image = > ImageCreate($width+($this->pad*2)+1,$height+($this->pad*2)+1); > $image = ImageCreateFromPNG("table_header.png"); > > $background = ImageColorAllocate($image, $this->bg_red, $this->bg_grn, > $this->bg_blu); > $foreground = ImageColorAllocate($image, $this->red, $this->grn, > $this->blu); > > if ($this->transparent) ImageColorTransparent($image, $background); > ImageInterlace($image, false); > > // render it. > ImageTTFText($image, $this->size, $this->rot, $offset_x+$this->pad, > $offset_y+$this->pad, $foreground, $this->font, $this->msg); > > // output PNG object. > imagePNG($image); > } > } > > $text = new textPNG; > > if (isset($msg)) $text->msg = $msg; // text to display > if (isset($font)) $text->font = $font; // font to use (include directory if > needed). > if (isset($size)) $text->size = $size; // size in points > if (isset($rot)) $text->rot = $rot; // rotation > if (isset($pad)) $text->pad = $pad; // padding in pixels around text. > if (isset($red)) $text->red = $red; // text color > if (isset($grn)) $text->grn = $grn; // .. > if (isset($blu)) $text->blu = $blu; // .. > if (isset($bg_red)) $text->bg_red = $bg_red; // background color. > if (isset($bg_grn)) $text->bg_grn = $bg_grn; // .. > if (isset($bg_blu)) $text->bg_blu = $bg_blu; // .. > if (isset($tr)) $text->transparent = $tr; // transparency flag (boolean). > > $text->draw(); > ?> > > > Aparte, por experiencia propia, te aconsejo que cambies a Apache for > Windows, por lo que veo estas usando Personal Web Server. Hay muchimas > razones por las cuales migrar de webserver, pero no entrare en eso aqui. > > Saludos, > Omar Rosado > E-Mail: mailto:omar@programmer.net > ICQ UIN: 1978451 > > -----Original Message----- > From: David Ayala [mailto:david@preus.scs.es] > Sent: Wednesday, October 11, 2000 7:58 AM > To: Lista PHP > Subject: [PHP-ES] PHP4+IIS4+NT+GD > > > _Hola lista.... > > tengo un pequeño problema con la librería GD, no consigo que me funcione > nada relacionado con los gráficos... > Después de muchos intentos en PHP3 cambie la versión a la 4.0.2. Se instaló > correctamente porque en el phpinfo(): > > gd > GD Supportenabled > GD Version1.6.2 or higher > FreeType Supportenabled > FreeType Linkagewith TTF library > GIF Supportenabled > PNG Supportenabled > JPG Supportenabled > WBMP Supportenabled > > He estado probando varios ejemplos bajados de la web pero ninguno lo consigo > hacer funcionar, siempre que el PHP intenta ejecutar la sentencia IMAGEGIF() > o JPG o PNG me da este error: > > Warning: imagegif: unable to open temporary file in > c:/inetpub/wwwroot/php/button.php3 on line 17 > > > Alguien le ha pasado algo similar o se le ocurre algo para solventar esto? > > David Ayala Villuendas > david@preus.scs.es > Unitat d´Informàtica DAP Reus-Altebrat > udi@preus.scs.es > > > > --------------------------------------------------------------------- > Para dar de baja la suscripción, mande un mensaje a: > lista-unsubscribe@phpes.com > > > > > --------------------------------------------------------------------- > Para dar de baja la suscripción, mande un mensaje a: > lista-unsubscribe@phpes.com > >

« previous php.general.es (#2312) next »