Ver Mensaje Individual
  #5 (permalink)  
Antiguo 09/07/2009, 15:12
Avatar de chulifo
chulifo
 
Fecha de Ingreso: abril-2009
Ubicación: perdido en codigos del PHP, pero aprendo rapido!
Mensajes: 524
Antigüedad: 15 años
Puntos: 18
Respuesta: Wenas ayuda con este codigoque genera inagenes

bueno consegui este codigo
Código PHP:
<?php
$button_text 
$_POST['button_text'];
$color $_POST['color'];

if (empty(
$button_text) || empty($color))
{
    echo 
"Hubo un error, Complete El Formulario Corecctamente!";
    exit;
}


$im imagecreatefrompng ("$color-boton.png");


$width_image imagesx($im);
$height_image imagesy($im);

$width_image_wo_margin $width_image - (18);
$height_image_wo_margin $height_image - (18);

$font_size 33;

do
{
    
$font_size--;
    
    
$bbox=imagettfbbox ($font_size0"arial.ttf"$button_text);
    
    
$right_text $bbox[2];
    
$left_text $bbox[0];
    
$width_text $right_text $left_text;
    
$height_text abs($bbox[7] - $bbox[1]);
    
} while ( 
$font_size>&&
         ( 
$height_text>$height_image_wo_margin ||
          
$width_text>$width_image_wo_margin )
         );
if ( 
$height_text>$height_image_wo_margin ||
    
$width_text>$width_image_wo_margin )
{
    echo 
"Disculpe Su Texto Es Muy Grande.<br>";
}
else
{
    
$text_x $width_image/2.0 $width_text/2.0;
    
$text_y $height_image/2.0 $height_text/2.0 ;
    
    if (
$left_text 0)
    
$text_x += abs($left_text);
    
    
$above_line_text abs($bbox[7]);
    
$text_y += $above_line_text;
    
    
$text_y -= 2;
    
$white imagecolorallocate ($im255255255);
    
imagettftext ($im$font_size0$text_x$text_y$white"arial.ttf"
                  
$button_text);
    
    
header ("Content-type: image/png");
    
imagepng ($im);
}
imagedestroy ($im);
?>
y genera la imagen bien y todo pero una ves generada le doy guardar y guarda un archivo .png pero dañado :S me ayudan Please!