Ver Mensaje Individual
  #1 (permalink)  
Antiguo 26/01/2008, 13:27
alexfs
 
Fecha de Ingreso: junio-2007
Ubicación: En mi casa
Mensajes: 82
Antigüedad: 17 años, 8 meses
Puntos: 2
convertir texto a imagen, ahora como lo hago para guardarla?

holaaa he encontrado un código que convertía un texto a una imagen, le he quitado el texto de defecto, i he creado una pagina principal, que da al usuario un campo para meter el texto i lo guarda en la variable text, i entonces ejecuta este script:

<?php
define( 'FONT_DIR', './' );
include( './image_functions.php' );

$text;
$req_height = 1;
$width = 400;

$text = preg_replace( '/\n/', ' ', $text ) ;
// grab font
$font = FONT_DIR . '/Vera.ttf';


// black and white here

$image = imagecreate( $width, $req_height );
$bg_color = ImageColorAllocate( $image, 255, 255, 255 );
$color = ImageColorAllocate( $image, 0, 0, 0 );

$textSize = 10;
$angle = 0;
$top = 10;
$left = 0;
$right = $width;
// ImageTTFText( $image, $size, $angle, $top, $left, $text_color, $font , $description );

$height = imageprintWordWrapped(&$image, $top, $left, $right, $font, $color, $text, $textSize, $halign="left") ;

if( $height > $req_height )
{
ImageDestroy( $image );
$image = imagecreate( $width, ( $height + ( 50 ) ));
$bg_color = ImageColorAllocate( $image, 255, 255, 255 );
$color = ImageColorAllocate( $image, 0, 0, 0 );
imageprintWordWrapped(&$image, $top, $left, $right, $font, $color, $text, $textSize, $halign="left") ;

}



header( 'Content-type: image/png' );
ImagePNG( $image );


?>

sabrías alguna forma para poder guardar esta imagen a un directorio? lo que queria hacer es guardar la imagen en una carpeta determinada i la imagen con un nombre aleatorio, pero he probado algunos códigos i no me acaban de funcionar del todo bien, GRACIAS