Ver Mensaje Individual
  #7 (permalink)  
Antiguo 07/02/2008, 05:06
Avatar de AJVEvoluzione
AJVEvoluzione
 
Fecha de Ingreso: agosto-2004
Ubicación: Buenos Aires
Mensajes: 195
Antigüedad: 20 años, 6 meses
Puntos: 1
Re: Como incorporarle un WaterMark (Marca de agua)

Me da el siguiente error:
Código HTML:
Warning: imagecolorallocate(): supplied argument is not a valid Image resource in /home/jorge/public_html/img.php on line 95

Warning: imagestring(): supplied argument is not a valid Image resource in /home/jorge/public_html/img.php on line 96

Warning: imagejpeg(): supplied argument is not a valid Image resource in /home/jorge/public_html/img.php on line 97
El codigo lo hice así:

Código PHP:
<?php   
define 
("MAX_SIZE","300000");    

function 
make_thumb($img_name,$filename,$new_w,$new_h)   
{   
$ext=getExtension($img_name);   
if(!
strcmp("jpg",$ext) || !strcmp("jpeg",$ext))   
$src_img=imagecreatefromjpeg($img_name);   

if(!
strcmp("png",$ext))   
$src_img=imagecreatefrompng($img_name);   

$old_x=imageSX($src_img);   
$old_y=imageSY($src_img);   

$ratio1=$old_x/$new_w;   
$ratio2=$old_y/$new_h;   
if(
$ratio1>$ratio2) {   
$thumb_w=$new_w;   
$thumb_h=$old_y/$ratio1;   
}   
else {   
$thumb_h=$new_h;   
$thumb_w=$old_x/$ratio2;   
}   

$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);   

imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);    

if(!
strcmp("png",$ext))   
imagepng($dst_img,$filename);    
else   
imagejpeg($dst_img,$filename);    

imagedestroy($dst_img);    
imagedestroy($src_img);    
}   

function 
getExtension($str) {   
$i strrpos($str,".");   
if (!
$i) { return ""; }   
$l strlen($str) - $i;   
$ext substr($str,$i+1,$l);   
return 
$ext;   
}   


$errors=0;   

if(isset(
$_POST['Submit']))   
{   

$image=$_FILES['image']['name'];   

if (
$image)    
{   
$filename stripslashes($_FILES['image']['name']);   

$extension getExtension($filename);   
$extension strtolower($extension);   
if ((
$extension != "jpg") && ($extension != "jpeg") && ($extension != "JPG") && ($extension != "JPEG") && ($extension != "PNG") && ($extension != "png"))    
{   
echo 
'<h1>Solo se pueden subir archivos .JPG .GIF o .PNG !!</h1>';   
$errors=1;   
}   
else   
{   

$size=getimagesize($_FILES['image']['tmp_name']);   
$sizekb=filesize($_FILES['image']['tmp_name']);   

if (
$sizekb MAX_SIZE*10000)   
{   
echo 
'<h1>El tamaño de la foto es demaciado grande !!</h1>';   
$errors=1;   
}   

$destinatario $_POST["gleria"];   
$image_name$_POST["pgleri"];   
$newname"".$destinatario."/images/".$image_name;   
$copied copy($_FILES['image']['tmp_name'], $newname);   
if (!
$copied)    
{   
echo 
'<h1>NO se pudo completar la copia !!</h1>';   
$errors=1;   
}   
else   
{   
$thumb_name"".$destinatario."/images/thumbs/".$image_name;   
$thumb=make_thumb($newname,$thumb_name,50,37);  
$grande"".$destinatario."/images/".$image_name;  
$fotofinal=make_thumb($newname,$grande,680,510);
$imagenbase=imagecreatefromjpeg($pict); 
$color ImageColorAllocate($imagenbase0xFF0xFF0xFF); 
ImageString($imagenbase500"logo.png"$color); 
Imagejpeg($imagenbase,$k23);  
}} }}   

if(isset(
$_POST['Submit']) && !$errors)    
{   
echo 
"<h1>Miniatura creada con éxito !!</h1>";   
echo 
'<img src="'.$thumb_name.'">';   
}   

?>   
<!-- next comes the form, you must set the enctype to "multipart/form-data" and use an input type "file" -->   
<html>   
   <head>   
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">   
<title>Subir Fotos</title>   
<meta NAME="ROBOT" CONTENT="NOINDEX,NOFOLLOW">   
<style>   
h1 { font-family: Verdana ; font-size: 14pt; color: #FFFFFF}   
th { font-family: Verdana ; font-size: 10pt; color: #FFFFFF}   
tr { font-family: Verdana ; font-size: 10pt; color: #FFFFFF}   
td { font-family: Verdana ; font-size: 10pt; color: #FFFFFF}   
p { font-family: Verdana ; font-size: 10pt; color: #FFFFFF}   
a {  font-family: Verdana ; font-weight: bold; font-size: 10pt; color: #0000FF }   
a:hover {  color: #FF0000}   
a{text-decoration:none}   
BODY{   
    margin-top: 10px;   
    margin-left: 10px;   
    margin-right: 0px;   
    margin-bottom: 0px;   
}   

</style>   
          
   </head>   
<body bgcolor="#000000">   
<form name="newad" method="post" enctype="multipart/form-data" action="">   
<table>   
<tr><td>Buscar Archivo: <input type="file" name="image" ></td></tr>   
<tr><td>Galería: <select name="gleria">   
            <option SELECTED VALUE="galeria1">Fotos Viaje 1</option>   
            <option VALUE="galeria2">Fotos Viaje 2</option>   
            <option VALUE="galeria3">Fotos Viaje 3</option>   
            <option VALUE="galeria4">Fotos Viaje 4</option>   
          </select> Foto N°: <select name="pgleri">   
            <option SELECTED VALUE="001.jpg">001</option>   
            <option VALUE="002.jpg">002</option>   
            <option VALUE="003.jpg">003</option>   
            <option VALUE="004.jpg">004</option>   
            <option VALUE="005.jpg">005</option>   
          </select></td></tr>   
<tr><td><input name="Submit" type="submit" value="Subir"></td></tr>   
</table>    
</form>   
</body>   
<html>