Ver Mensaje Individual
  #1 (permalink)  
Antiguo 06/06/2008, 09:28
Avatar de pato12
pato12
 
Fecha de Ingreso: septiembre-2007
Ubicación: Salta
Mensajes: 1.620
Antigüedad: 16 años, 8 meses
Puntos: 101
Aporte: Escribir una imagen facilmente

Hola,
Hice un class para para editar facilmente imagenes, se llama:
Cita:
EasyWriteImage
Consiste en 1 solo archivo que se llama EasyWriteImage.class.php
Es muy facil de usar.
Class:
EasyWriteImage.class.php
Código PHP:
///////////////////////////////
//  Class By Pato12          //
//  De Forosdelweb.com      //
//  Titulo: EasyWriteImage //
//  Version: 1.0          //
///////////////////////////
class EasyWriteImage
{
var 
$name;
var 
$y;
var 
$x;
var 
$texto;
var 
$r;
var 
$g;
var 
$b;
var 
$font;
var 
$imagen;
//
function font($t,$v){
if(
$v){
$this->font=$t;
}
return 
$this->font;
}
//
function name($t,$v){
if(
$v){
$this->name=$t;
}
return 
$this->name;
}
//
function y($t,$v){
if(
$v){
$this->y=$t;
}
return 
$this->y;
}
//
function x($t,$v){
if(
$v){
$this->x=$t;
}
return 
$this->x;
}
//
function texto($t,$v){
if(
$v){
$this->texto=$t;
}
return 
$this->texto;
}
//
function r($t,$v){
if(
$v){
$this->r=$t;
}
return 
$this->r;
}
//
function g($t,$v){
if(
$v){
$this->g=$t;
}
return 
$this->g;
}
//
function b($t,$v){
if(
$v){
$this->b=$t;
}
return 
$this->b;
}
//
function imagen($t,$v){
if(
$v){
$this->imagen=$t;
}
return 
$this->imagen;
}
function 
insertar_texto(){
$name=$this->name;
$texto=$this->texto;
$x=$this->x;
$y=$this->y;
$r=$this->r;
$g=$this->g;
$b=$this->b;
$font=$this->font;
$imagen=$this->imagen;
$image imagecreatefromjpeg($imagen);
$colText imagecolorallocate($image,$r,$g,$b);
imagestring($image,$font,$x,$y,$texto,$colText);
imagejpeg($image,$name.".jpg"); 
imagedestroy($image);
}
function 
insertar(){
echo 
"<img src='".$this->name.".jpg'/>";
}

y para usarlo el siguiente codigo:
Código PHP:
$escribir= new EasyWriteImage();
$escribir->font(5,true);// Tamaño del texto (max 5)
$escribir->name("2",true); // Nombre del archivo(va a ser .jpg)
$escribir->texto("Pato es un capo",true);// Texto
$escribir->x(20,true); // Lugar
$escribir->y(0,true);// Lugar
$escribir->r(0,true); // Porsentaje de color rojo
$escribir->g(0,true);// Porsentaje de color verde
$escribir->b(0,true);// Porsentaje de color azul
$escribir->imagen("2.jpg",true); // Imagen a escribir (tiene que aser jpg o jpeg)
$escribir->insertar_texto();// Escribimos el texto en una nueva imagen ( la nombramos arriba)
$escribir->insertar();// Lo insertamos
/* Esto crea un archivo igual al otro, pero si queres que se cambie para siempre hay
que poner de nombrelo mismo que el de la imagen: 
Si la imagen a editar se llama image.jpg
y queremos que los cambios sean permamentes hay que poner de nombre del archivo image en la
siguiente linea:
$escribir->name("image",true);
///////////////////////
Colores:
Blanco- 255,255,255
Gris- 128,128,128
Negro- 0,0,0
*/ 
Espero que le sea util.
Espero sus comentarios
Graicas
Salu2
__________________
Half Music - www.halfmusic.com