Foros del Web » Programando para Internet » PHP »

crear imagen

Estas en el tema de crear imagen en el foro de PHP en Foros del Web. Hola a todos, estoy intentando generar una imagen desde una captura de pantalla hecha en flash, en un servidor con php 4 y windows me ...
  #1 (permalink)  
Antiguo 29/11/2007, 03:31
 
Fecha de Ingreso: julio-2003
Mensajes: 58
Antigüedad: 20 años, 9 meses
Puntos: 0
crear imagen

Hola a todos,

estoy intentando generar una imagen desde una captura de pantalla hecha en flash, en un servidor con php 4 y windows me genera la imagen correctamente pero en un php5 y linux me genera una imagen en blanco, alguien sabe que puede ser? Este es el codigo de php que uso:

error_reporting(E_ALL);
/**
* Get the width and height of the destination image
* from the POST variables and convert them into
* integer values
*/
$w = (int)$_POST['width'];
$h = (int)$_POST['height'];

// create the image with desired width and height

$img = imagecreatetruecolor($w, $h);

// now fill the image with blank color
// do you remember i wont pass the 0xFFFFFF pixels
// from flash?
imagefill($img, 0, 0, 0xFFFFFF);

$rows = 0;
$cols = 0;

// now process every POST variable which
// contains a pixel color
for($rows = 0; $rows < $h; $rows++){
// convert the string into an array of n elements
$c_row = explode(",", $_POST['px' . $rows]);
for($cols = 0; $cols < $w; $cols++){
// get the single pixel color value
$value = $c_row[$cols];
// if value is not empty (empty values are the blank pixels)
if($value != ""){
// get the hexadecimal string (must be 6 chars length)
// so add the missing chars if needed
$hex = $value;
while(strlen($hex) < 6){
$hex = "0" . $hex;
}
// convert value from HEX to RGB
$r = hexdec(substr($hex, 0, 2));
$g = hexdec(substr($hex, 2, 2));
$b = hexdec(substr($hex, 4, 2));
// allocate the new color
// N.B. teorically if a color was already allocated
// we dont need to allocate another time
// but this is only an example
$test = imagecolorallocate($img, $r, $g, $b);
// and paste that color into the image
// at the correct position
imagesetpixel($img, $cols, $rows, $test);
}
}
}

// print out the correct header to the browser
header("Content-type:image/jpeg");
// display the image
imagejpeg($img, "mark.jpg",90);
  #2 (permalink)  
Antiguo 29/11/2007, 04:55
Avatar de RUX
RUX
 
Fecha de Ingreso: enero-2004
Ubicación: Las Palmas de Gran Canari
Mensajes: 566
Antigüedad: 20 años, 3 meses
Puntos: 0
Re: crear imagen

Hola, ¿Ese php5 tiene las librerias necesarias para generar imagenes?

SALUDOS
Ruymán Trujillo
__________________
Rux.es - Sitio Personal | IslaRock.com - Todo Rock
  #3 (permalink)  
Antiguo 29/11/2007, 05:06
Avatar de popobcn
Moderador
 
Fecha de Ingreso: noviembre-2006
Ubicación: Cerdanyola del Vallès
Mensajes: 3.892
Antigüedad: 17 años, 5 meses
Puntos: 1142
Re: crear imagen

Hola,

Para revisar si tienes o no instaladas las librerias GD puedes hacer lo siguiente:

Código PHP:
<?
$array
=gd_info ();
foreach (
$array as $key=>$val) {
  
  if (
$val===true) {
    
$val="Enabled";
  }

  if (
$val===false) {
    
$val="Disabled";
  }

  echo 
"$key: $val <br />\n";

}
?>
(Código extraido de la página de php.net
Te mostrará información relativa a la versión y los formatos soportados.

Saludos,
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 11:04.