Exemplo n.º 1
0
 /**
  * Adding file to local directory
  * 
  * @array $arFields('path_from', 'path_to', 'width', 'height')
  */
 public static function add($arFields)
 {
     if (file_exists($arFields["path_from"])) {
         if (!empty($arFields["path_to"]) && file_exists($arFields["path_to"])) {
             return;
         }
         //print_r($arFields);
         $image = new \Eventviva\ImageResize($arFields["path_from"]);
         list($width, $height, $type, $attr) = getimagesize($arFields["path_from"]);
         if ($arFields["width"] && $arFields["height"] && ($arFields["width"] != $width || $arFields["height"] != $height)) {
             $image->crop($arFields["width"], $arFields["height"]);
         }
         if (!$arFields["path_to"]) {
             $path_parts = pathinfo($arFields["path_from"]);
             $file_name = $path_parts["filename"];
             $image->save($_SERVER["DOCUMENT_ROOT"] . "/upload/epg/" . $file_name . ".jpg");
         } else {
             $image->save($arFields["path_to"]);
         }
     }
 }
Exemplo n.º 2
0
<?php

/**
 * Redimenssionne une photo en 640x340 px pour la page d'accueil de la version mobile
 *
 * PHP Version 5.3.3
 *
 * @category General
 * @package  ArchiWiki
 * @author   Pierre Rudloff <*****@*****.**>
 * @license  GNU GPL v3 https://www.gnu.org/licenses/gpl.html
 * @link     http://archi-wiki.org/
 * */
require_once 'vendor/autoload.php';
$config = new ArchiConfig();
$req = "\n        SELECT dateUpload\n        FROM  historiqueImage\n        WHERE idHistoriqueImage = " . mysql_real_escape_string($_GET["id"]);
$res = $config->connexionBdd->requete($req);
$image = mysql_fetch_object($res);
$path = "images/grand/" . $image->dateUpload . "/" . $_GET["id"] . ".jpg";
$image = new \Eventviva\ImageResize($path);
$image->crop(640, 340, true);
$image->output();
<?php

/**
 * Redimenssionne une photo en 130x130 px pour la version mobile
 *
 * PHP Version 5.3.3
 *
 * @category General
 * @package  ArchiWiki
 * @author   Pierre Rudloff <*****@*****.**>
 * @license  GNU GPL v3 https://www.gnu.org/licenses/gpl.html
 * @link     http://archi-wiki.org/
 * */
require_once 'vendor/autoload.php';
$config = new ArchiConfig();
$path = "images/placeholder.jpg";
if (isset($_GET["id"]) && !empty($_GET["id"])) {
    $req = "\n            SELECT dateUpload\n            FROM  historiqueImage\n            WHERE idHistoriqueImage = '" . mysql_real_escape_string($_GET["id"]) . "'";
    $res = $config->connexionBdd->requete($req);
    $image = mysql_fetch_object($res);
    if ($image) {
        $tempPath = "images/moyen/" . $image->dateUpload . "/" . $_GET["id"] . ".jpg";
        if (file_exists($tempPath)) {
            $path = $tempPath;
        }
    }
}
$image = new \Eventviva\ImageResize($path);
$image->crop(130, 130, true);
$image->output();