![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
Habría que incorporarlo a un php exactamente donde convierte la imagen en 680x510.
Aca esta la marca de agua:
Código PHP:
$file = $_GET['i'];
$watermark = @imagecreatefrompng("logo.png");
@imagealphablending($watermark, true);
$imagens=@imagecreatefromjpeg($file);
$imageWidth=@imageSX($imagens);
$imageHeight=@imageSY($imagens);
$watermarkWidth=@imageSX($watermark);
$watermarkHeight=@imageSY($watermark);
$coordinate_X = ($imageWidth - 5) - ($watermarkWidth);
$coordinate_Y = ($imageHeight - 5) - ($watermarkHeight);
@imagecopy($imagens, $watermark, $coordinate_X, $coordinate_Y, 0, 0, $watermarkWidth, $watermarkHeight);
@imagejpeg($imagens);
Código PHP:
<?php
define ("MAX_SIZE","3000000");
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*3000000)
{
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);
$imh= "".$destinatario."/images/".$image_name;
$img4=make_thumb($newname,$imh,680,510);
}} }}
if(isset($_POST['Submit']) && !$errors)
{
echo "<h1>Foto y Miniatura creada con éxito !!</h1>";
echo '<img src="'.$thumb_name.'">';
}
?>
<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="Gal1">Galeria 1</option>
<option VALUE="Gal2">Galeria 2</option>
<option VALUE="Gal3">Galeria 3</option>
<option VALUE="Gal4">Galeria 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>
</select></td></tr>
<tr><td><input name="Submit" type="submit" value="Subir"></td></tr>
</table>
</form>
</body>
<html>