コード例 #1
0
ファイル: Documents.php プロジェクト: bersace/strass
 function storeFile($tmp)
 {
     $fichier = $this->getFichier($this->_data);
     if (!file_exists($dossier = dirname($fichier))) {
         mkdir($dossier, 0755, true);
     }
     if (isset($_ENV['STRASS_UNIT_TEST'])) {
         $ret = copy($tmp, $fichier);
     } else {
         $ret = move_uploaded_file($tmp, $fichier);
     }
     if ($ret === false) {
         throw new Exception("Impossible de copier le fichier !");
     }
     $vignette = $this->getCheminVignette($this->_data);
     $load = $fichier;
     if ($this->suffixe == 'pdf') {
         $load .= '[0]';
     }
     try {
         @Strass_Vignette::reduire($load, $vignette, true);
     } catch (Exception $e) {
         /* pas supporté par Imagick */
         error_log("Échec de la vignette de " . $load . " : " . $e->getMessage());
     }
 }
コード例 #2
0
ファイル: Photos.php プロジェクト: bersace/strass
 function storeFile($path)
 {
     $activite = $this->findParentActivites();
     /* date */
     $exif = @exif_read_data($path);
     if ($exif && array_key_exists('DateTimeOriginal', $exif)) {
         preg_match("`(\\d{4})[:-](\\d{2})[:-](\\d{2}) (\\d{2}):(\\d{2}):(\\d{2})`", $exif['DateTimeOriginal'], $match);
         $this->date = $match[1] . '-' . $match[2] . '-' . $match[3] . ' ' . $match[4] . ':' . $match[5] . ':' . $match[6];
     } else {
         $this->date = $activite->fin;
     }
     $dossier = $activite->getDossierPhoto();
     if (!file_exists($dossier)) {
         mkdir($dossier, 0755, true);
     }
     $suffixe = '.jpeg';
     $vignette = $dossier . '/' . $this->slug . '-vignette' . $suffixe;
     $fichier = $dossier . '/' . $this->slug . $suffixe;
     $config = Zend_Registry::get('config');
     $photo = Strass_Vignette::charger($path, $fichier, true);
     $width = $photo->getWidth();
     $height = $photo->getHeight();
     $MAX = $config->get('photo/taille', 2048);
     if (min($width, $height) > $MAX) {
         $photo->scale($MAX, $MAX);
     }
     $photo->ecrire();
     Strass_Vignette::decouper($photo, $vignette);
     $this->save();
 }
コード例 #3
0
ファイル: Unites.php プロジェクト: bersace/strass
 function storeImage($path)
 {
     Strass_Vignette::reduire($path, $this->getCheminImage(null, false));
 }
コード例 #4
0
ファイル: GDTest.php プロジェクト: bersace/strass
 function testDecouperPng2Png()
 {
     Strass_Vignette::decouper(dirname(__FILE__) . '/images/transparente.png', 'gd-png-crop.png');
 }
コード例 #5
0
ファイル: Vignette.php プロジェクト: bersace/strass
 function __construct($src, $dst, $flatten)
 {
     parent::__construct($dst);
     $this->target = null;
     if ($src instanceof self) {
         /* prendre la propriété de la resource */
         $this->orig = imagecreatetruecolor($src->getWidth(), $src->getHeight());
         imagecopy($this->orig, $src->orig, 0, 0, 0, 0, $src->getWidth(), $src->getHeight());
     } else {
         if (strpos($src, ']') !== false) {
             throw new Exception("Multipage non supporté");
         }
         $format = pathinfo(strtolower($src), PATHINFO_EXTENSION);
         switch ($format) {
             case 'jpeg':
             case 'jpg':
                 $this->orig = imagecreatefromjpeg($src);
                 break;
             case 'png':
                 $this->orig = imagecreatefrompng($src);
                 break;
             case 'gif':
                 $this->orig = imagecreatefromgif($src);
                 break;
             default:
                 $this->orig = imagecreatefromstring(file_get_contents($src));
         }
         if ($this->orig === false) {
             throw new Exception("Impossible de charger le fichier " . $src);
         }
         $this->target = $this->orig;
     }
 }