Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/04/2006, 20:47
Avatar de adex
adex
 
Fecha de Ingreso: marzo-2002
Ubicación: Lima, Perú, América Latina
Mensajes: 445
Antigüedad: 22 años, 1 mes
Puntos: 0
Pregunta Convertir texto a imagen

Amigos del Foro:

tengo el siguiente script que convierte texto (email) a una imagen
todo esta bien hasta ahi, pero lo que no consigo es meter los datos
de una consulta sql
me hechan una mano por favor?

email_src.php
Código PHP:
<?
/*
Programa PHP para encriptar correo electronico, copiar en el servidor PHP
*/


header("Content-Type: image/png");

// get amounts and titles from session.
$text base64_decode($_GET['text']);

// calculate required width and height of image
$pic_width strlen($text)*6;
$pic_height 12;

// create image
$pic ImageCreate($pic_width+1,$pic_height+1);

// allocate colours
$white ImageColorAllocate($pic,255,255,255);
$grey  ImageColorAllocate($pic,200,200,200);
$lt_grey  ImageColorAllocate($pic,210,210,210);
$black ImageColorAllocate($pic,0,0,0);
$trans_temp ImageColorAllocate($pic,254,254,254);
$transparent ImageColorTransparent($pic,$trans_temp);

// using isset not !empty, as values could=0, therefore "empty"
if(isset($_GET['r']) && isset($_GET['g']) && isset($_GET['b']))
{
    
$user ImageColorAllocate($pic,intval($_GET['r']),intval($_GET['g']),intval($_GET['b']));
} else {
    
$user $lt_grey;
}

// transparent fill for background 
ImageFilledRectangle($pic,0,0,$pic_width,$pic_height,$trans_temp);

// draw text
ImageString($pic,2,0,0,$text,$user);

// output image
ImagePNG($pic);

// remove image from memory
ImageDestroy($pic);
?>
print_email_src.php

Código PHP:
<?

// encripta direccion de correo, puede ser usada con una variable: 
// ejemplo: base64_encode($mivariable);

//$string = base64_encode('[email protected]');
$string base64_encode('$datos-de-sql');

// colores de la imagen r= cantidad de rojo, g= cantidad de verde, 
// b= cantidad de azul, valor maximo 255
$email_encoded '<img src="rip_email_src.php?r=100&g=150&b=0&text='.$string.'">';

// escribe la imagen del correo electronico
echo $email_encoded;
?>
muchas gracias!