Beispiel #1
0
    highlight_file(__FILE__);
    exit;
}
//ruta de la imagen
$imagen = $_GET['imagen'];
//se busca el tamaño de la imagen
$tama_imag = getimagesize($imagen);
$ancho_img = $tama_imag[0];
$alto_img = $tama_imag[1];
//incluimos la librería
include_once "funcionalidades/PHPImagen.lib.php";
//Instanciamos la clase
$imagen = new Imagen($imagen);
//si el ancho es mayor a alcho real de la imagen el ancho sera el ancho real
$nuevo_ancho = $_GET['ancho'] <= $ancho_img ? $_GET['ancho'] : NULL;
//si el alto es mayor a alto real de la imagen el alto sera el ancho real
$nuevo_alto = $_GET['alto'] <= $alto_img ? $_GET['alto'] : NULL;
//si se desea croppear la imagen se especifica el cut
$cut = isset($_GET['cut']) ? true : false;
//Redimension de la imagen. Los parámetros
$imagen->resize($nuevo_ancho, $nuevo_alto, $cut);
// Aplicación de la marca de agua
if ($_GET['mark'] !== "false") {
    $imagen->watermark("imagenes/favicon2.png", -1, -1, false, 0);
}
//Si se pide que se baje la imagen
if (isset($_GET['download'])) {
    $imagen->doDownload();
} else {
    $imagen->doPrint();
}
         // echo "ERROR: No se pudo crear la carpeta '$path_aux/thumbs'";
         // echo $path;
         if (move_uploaded_file($foto_tmp, $path)) {
             // $nombre_archivo = $this -> slugify($anuncio -> titulo);
             // $nombre_archivo .= '_' . $i+1 . '-' . rand(1000, 99999) . '.jpg';
             // $sql = "INSERT INTO {$this -> tabla_imagenes_inmobiliaria} SET url = '$ruta_aux/" . $nombre_archivo ."', anuncio_id = 'id'";
             $_SESSION['nuevo_anuncio']['img'][] = array('nombre' => $time . $foto_name, 'size' => $tam);
             if (copy($path, $path_thumbs)) {
                 //thumbs
                 if (!Imagen::redimensionar($path_thumbs, MAX_WIDTH_THUMBS, MAX_HEIGHT_THUMBS)) {
                     unlink($path);
                     return 0;
                 }
             }
             Imagen::redimensionar($path, MAX_WIDTH, MAX_HEIGHT);
             Imagen::watermark($path);
             $data = $time . $foto_name;
             // echo $data;
         } else {
             unlink($path);
             return 0;
         }
         // }
         echo $data;
     } else {
         return 0;
     }
     break;
 default:
     return 0;
     break;