コード例 #1
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;
     }
 }