Foros del Web » Programando para Internet » PHP »

Crear JPG con texto raro

Estas en el tema de Crear JPG con texto raro en el foro de PHP en Foros del Web. Hola a todos, Estoy tratando de crear un .jpg con texto de caracteres raros eje. Ł y mas, y no encuentro la manera. Pues mis ...
  #1 (permalink)  
Antiguo 05/09/2008, 03:51
hmv
 
Fecha de Ingreso: abril-2005
Mensajes: 323
Antigüedad: 19 años
Puntos: 0
Busqueda Crear JPG con texto raro

Hola a todos,

Estoy tratando de crear un .jpg con texto de caracteres raros eje. Ł y mas, y no encuentro la manera. Pues mis clientes son de paises de europa del este.
nota: Ł ='&#321';

Código PHP:
// create example image
$im imagecreate(20020);
$bg imagecolorallocate($im255255255);
$textcolor imagecolorallocate($im00255);
$text "Ł--ľščťžýáíéúäňôď...Ł abc"
//$text='Ł';

//simple convert string
$string iconv("ISO-8859-1""UTF-8"$text);

// write converted string at the top left
imagestring($im400$string$textcolor);

// output the image
header("Content-type: image/png");
header("Content-Type" content="text/html; charset=iso-8859-1");
imagepng($im); 
muchas gracias.
  #2 (permalink)  
Antiguo 05/09/2008, 06:53
hmv
 
Fecha de Ingreso: abril-2005
Mensajes: 323
Antigüedad: 19 años
Puntos: 0
Respuesta: Crear JPG con texto raro

Alguien tiene alguna idea???
  #3 (permalink)  
Antiguo 05/09/2008, 07:11
Avatar de farra  
Fecha de Ingreso: marzo-2008
Ubicación: Aqui estoy
Mensajes: 574
Antigüedad: 16 años, 1 mes
Puntos: 20
Respuesta: Crear JPG con texto raro

Código PHP:
<?php
session_start
();
function 
randomText($length) {
    
$pattern "123456789abcdefghijklmnopqrstuvwxyz";
    for(
$i=0;$i<$length;$i++) {
      
$key .= $pattern{rand(0,34)};
    }
    return 
strtolower($key);
}

$_SESSION['tmptxt'] = randomText(8);
$captcha imagecreatefromgif("bgcaptcha.gif");
$colText imagecolorallocate($captcha000);
imagestring($captcha5167$_SESSION['tmptxt'], $colText);

header("Content-type: image/gif");
imagegif($captcha);
?>
Código HTML:
<?php
if (!isset($_SESSION)) {
  session_start();
}
if ($_POST['action'] == "checkdata") {
$captchausersend=strtolower($_POST['tmptxt']);
	if ($_SESSION['tmptxt'] == $captchausersend) {
		$valido="SI";
	} else {
		$valido="NO";
	}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>CAPTCHA con PHP</title>
<meta name="description" content="CAPTCHA con PHP: ejemplo para demostrar la creacion de Captcha con PHP." />
<link href="styles.css" rel="stylesheet" type="text/css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td align="center" class="descdet">
	<div class="bordeder">
		<strong class="subder">CAPTCHA con PHP </strong><br>
		Ingresar el texto mostrado en la imagen <br>
		<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
		  <img src="captcha.php" width="100" height="30" vspace="3"><br>
		  <input name="tmptxt" type="text" size="30"><br>
		  <input name="btget" type="submit" class="boton" value="Verificar Codigo">
		  <input name="action" type="hidden" value="checkdata">
		</form>
	</div>
	</td>
  </tr>
</table>
</body>
</html> 

en la linea:
$pattern = "123456789abcdefghijklmnopqrstuvwxyz";

reemplaza por los simbolos..
__________________
Firma:
Es mas dificil para el mono entender que el hombre desciende de el....

PD: Siempre doy karma al que me da una buena respuesta... ;0)
  #4 (permalink)  
Antiguo 08/09/2008, 05:25
hmv
 
Fecha de Ingreso: abril-2005
Mensajes: 323
Antigüedad: 19 años
Puntos: 0
Busqueda

sigue sin funcionar, cuando le pongo el caracter raro, la imagen me sale en blanco.

Por lo visto el catcha solo sirve para crear imagenes con texto normal.

Última edición por GatorV; 08/09/2008 a las 09:25
  #5 (permalink)  
Antiguo 08/09/2008, 09:25
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Crear JPG con texto raro

Hola hmv,

La fuente que utilices tiene que tener todos los caracteres del texto "raro" que quieras imprimir, de lo contrario no podras ponerlos en pantalla.

Saludos.
  #6 (permalink)  
Antiguo 08/09/2008, 09:29
hmv
 
Fecha de Ingreso: abril-2005
Mensajes: 323
Antigüedad: 19 años
Puntos: 0
Busqueda Respuesta: Crear JPG con texto raro

Gracias por responder,

Cuando imprimo el caracter a traves de un echo "Ł" o por su código echo "&#321", este si lo imprime por pantalla, el problema es cuando intento poner este caracter en la imagen.
  #7 (permalink)  
Antiguo 09/09/2008, 08:15
hmv
 
Fecha de Ingreso: abril-2005
Mensajes: 323
Antigüedad: 19 años
Puntos: 0
Busqueda Respuesta: Crear JPG con texto raro

Algúna otra idea?????
  #8 (permalink)  
Antiguo 10/09/2008, 08:22
hmv
 
Fecha de Ingreso: abril-2005
Mensajes: 323
Antigüedad: 19 años
Puntos: 0
Respuesta: Crear JPG con texto raro

Intente con imagettftext(), pero el problema persite.
  #9 (permalink)  
Antiguo 10/09/2008, 18:05
 
Fecha de Ingreso: abril-2008
Mensajes: 88
Antigüedad: 16 años
Puntos: 5
Respuesta: Crear JPG con texto raro

Yo Uso el siguiente codigo para generar Imagenes aleatorias para verificacion de usuarios,
pero quiza te pueda ayudar. me contas!
$valoraleatorio es la variable donde coloco los datos pero intenta ingresarle los caracteres raros

<?php
$ancho=100;
$alto=30;
$imagen=imageCreate($ancho,$alto);
$amarillo=ImageColorAllocate($imagen,150,200,105);
ImageFill($imagen,0,0,$amarillo);
$rojo=ImageColorAllocate($imagen,255,0,0);
$valoraleatorio=rand(100000,999999);
ImageString($imagen,5,25,5,$valoraleatorio,$rojo);
for($c=0;$c<=2;$c++)
{
$x1=rand(0,$ancho);
$y1=rand(0,$alto);
$x2=rand(0,$ancho);
$y2=rand(0,$alto);
ImageLine($imagen,$x1,$y1,$x2,$y2,$rojo);
}
Header ("Content-type: image/jpeg");
ImageJPEG ($imagen);
ImageDestroy($imagen);
?>
  #10 (permalink)  
Antiguo 10/09/2008, 22:11
Avatar de pepeverastegui  
Fecha de Ingreso: septiembre-2008
Ubicación: Pedernales, Michoacan
Mensajes: 82
Antigüedad: 15 años, 7 meses
Puntos: 2
Respuesta: Crear JPG con texto raro

Cita:
Iniciado por farra Ver Mensaje
Código PHP:
<?php
session_start
();
function 
randomText($length) {
    
$pattern "123456789abcdefghijklmnopqrstuvwxyz";
    for(
$i=0;$i<$length;$i++) {
      
$key .= $pattern{rand(0,34)};
    }
    return 
strtolower($key);
}

$_SESSION['tmptxt'] = randomText(8);
$captcha imagecreatefromgif("bgcaptcha.gif");
$colText imagecolorallocate($captcha000);
imagestring($captcha5167$_SESSION['tmptxt'], $colText);

header("Content-type: image/gif");
imagegif($captcha);
?>
no se mucho de esto pero buneo
no jalaria el codigo anterior con la funcion base64_decode()???
  #11 (permalink)  
Antiguo 10/09/2008, 22:37
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: Crear JPG con texto raro

Hola hmv,

Si lees el post que te puse, te digo que todo depende de la fuente que uses en tu imagen, si la fuente no tiene esos caracteres no se puede imprimir.

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 07:42.