<?php
//Obtenemos la imagen
$img = $_GET['img'];
//Evitamos que se cachee la imagen
header("Expires: Tue, 03 Jul 2001 06:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header('Content-type: image/jpeg');
//obtenemos la extencion del archivo
$filetype = substr($img,strlen($img)-4,4);
//Vemos que tipo de archivo es
$filetype = strtolower($filetype);
if($filetype == ".gif") $image = imagecreatefromgif($img);
if($filetype == ".jpg") $image = imagecreatefromjpeg($img);
if($filetype == ".png") $image = imagecreatefrompng($img);
if (!$image) die();
//obtenemos el tamaño de la imagen
$img_w = imagesx($image);
$img_h = imagesy($image);
//Si el tamaño de la imagen es menor a 150 no hacemos nada
if ($img_w < "50") {
imagejpeg($image, null, $q); die();
}
//Color negro transparente, el valor 30 es la transparencia
$TT = imagecolorallocatealpha($image, 0, 0, 0, 30);
//Color blanco
$color = imagecolorallocate($image,255,255,255);
//Creamos un rectangulo que tape toda la imagen
imagefilledrectangle($image, 0, 0, imagesx($image), imagesy($image), $TT);
//Agregamos el texto
imageCenterString($image,5,'Click para Ver Imagen',$color);
//Creamos la imagen en pantalla
imagejpeg($image, null, 100);
//Vaciamos la memoria
imagedestroy($image);
//Esta funcion esta encargada de centrar el texto en la imagen
function imageCenterString(&$img, $font, $text, $color){
if($font < 0 || $font > 5){ $font = 0; }
$num = array(array(4.6, 6),
array(4.6, 6),
array(5.6, 12),
array(6.5, 12),
array(7.6, 16),
array(8.5, 16));
$width = ceil(strlen($text) * $num[$font][0]);
$x = imagesx($img) - $width - 8;
$y = Imagesy($img) - ($num[$font][1] + 2);
imagestring($img, $font, $x/2, $y/2, $text, $color);
}
?>