Foros del Web » Programando para Internet » PHP »

Editor imágenes php

Estas en el tema de Editor imágenes php en el foro de PHP en Foros del Web. Que tal amigos de forosdelweb! vengo a pedirles ayuda a un problema que me ah surgido hace unos días, y es que necesito insertar varios ...
  #1 (permalink)  
Antiguo 27/05/2012, 20:06
 
Fecha de Ingreso: septiembre-2011
Mensajes: 34
Antigüedad: 12 años, 7 meses
Puntos: 1
Editor imágenes php

Que tal amigos de forosdelweb! vengo a pedirles ayuda a un problema que me ah surgido hace unos días, y es que necesito insertar varios textos en una imagen,el código que tengo por ahora es :

Código PHP:
 <?php
$upload
=$_POST['img-url'];
$SourceFile $upload;
$rnd=rand(0,999999);
$rnd2=$rnd*2;
$rndR=rand(0,987);
$rnd3=$rnd2-$rndR;
$var="_elcoso";
$var2="_$rnd2";
$var3="_$rnd3";
$DestinationFile "$rnd".$var."$var2"."$var3".".jpg"
$WaterMarkText 'MARCADEAGUA.com';

watermarkImage ($SourceFile$WaterMarkText$DestinationFile);
?>
<?php
function watermarkImage ($SourceFile$WaterMarkText$DestinationFile) { 
   list(
$width$height) = getimagesize($SourceFile);
   
$image_p imagecreatetruecolor($width$height);
   
$image imagecreatefromjpeg($SourceFile);
   
imagecopyresampled($image_p$image0000$width$height$width$height); 
   
$black imagecolorallocate($image_p064128);
   
$font 'arial.ttf';
   
$font_size 12
   
$left = ($width 3) ;
   
$top = ($height 2) ;
   
   
$bot = ($top 2) ;
   
$fbop=$bot-5;
 
imagettftext($image_p$font_size0$left$fbop$black$font$WaterMarkText);


   if (
$DestinationFile<>'') {
      
imagejpeg ($image_p$DestinationFile100); 
                   echo 
"<meta http-equiv=refresh content=0;url=http://localhost/$DestinationFile>";
   } else {
      
header('Content-Type: image/jpeg');
      
imagejpeg($image_pnull100);
   };
   
imagedestroy($image); 
   
imagedestroy($image_p); 
};
?>
Me crea la marca de agua,estupendo,pero quiero añadir otra cadena de texto,intento con :

$WaterMarkText_DOS = '2DAMARCADEAGUA.com';
Y:
imagettftext($image_p, $font_size, 0, $left, $fbop, $black, $font, $WaterMarkText_DOS );

Le cambio de posición y todo pero no funciona,sólo me inserta una marca de agua,espero su ayuda amigos,porfavor me urge para un proyecto del bachillerato(colegio).
  #2 (permalink)  
Antiguo 28/05/2012, 04:45
 
Fecha de Ingreso: mayo-2004
Mensajes: 102
Antigüedad: 20 años
Puntos: 5
Respuesta: Editor imágenes php

Intenta asi:

<?php
function watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile) {
list($width, $height) = getimagesize($SourceFile);
$image_p = imagecreatetruecolor($width, $height);
$image = imagecreatefromjpeg($SourceFile);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width, $height);
$black = imagecolorallocate($image_p, 0, 64, 128);
$font = 'arial.ttf';
$font_size = 12;
$left = ($width / 3) ;
$top = ($height / 2) ;

$bot = ($top * 2) ;
$fbop=$bot-5;

imagettftext($image_p, $font_size, 0, $left, $fbop, $black, $font, $WaterMarkText);


if ($DestinationFile<>'') {
imagejpeg ($image_p, $DestinationFile, 100);
echo "<meta http-equiv=refresh content=0;url=http://localhost/$DestinationFile>";
} else {
header('Content-Type: image/jpeg');
imagejpeg($image_p, null, 100);
};
imagedestroy($image);
imagedestroy($image_p);
};
?>
<?php
$upload=$_POST['img-url'];
$SourceFile = $upload;
$rnd=rand(0,999999);
$rnd2=$rnd*2;
$rndR=rand(0,987);
$rnd3=$rnd2-$rndR;
$var="_elcoso";
$var2="_$rnd2";
$var3="_$rnd3";
$DestinationFile = "$rnd".$var."$var2"."$var3".".jpg";
$WaterMarkText = 'MARCADEAGUA.com';

watermarkImage ($SourceFile, $WaterMarkText, $DestinationFile);
?>


A simple vista podria ser este el problema ya qeu estas llamando a la funcion antes de que se carge.
Prueba y si no funciona avisa, saludos!
__________________
Bruno Quintana

Etiquetas: editor, imagenes
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 22:18.