Example #1
0
 /**
  * @return Uploader
  */
 public function prepare()
 {
     if (is_array($this->session)) {
         $this->digital = (string) $this->session['digital'];
         $this->public = (bool) $this->session['fg_publico'];
     } else {
         throw new Exception('Não foi possível recuperar os dados da sessão!');
     }
     if ($this->_isFile()) {
         $this->hash = (string) hash_file('md5', $this->file["tmp_name"]);
         $this->type = (string) substr($this->file["name"], -3);
         $this->size = (int) $this->file["size"];
         try {
             MagickReadImage($object = NewMagickWand(), $this->file["tmp_name"]);
             $this->width = MagickGetImageWidth($object);
             $this->height = MagickGetImageHeight($object);
             $this->codeType = MagickGetImageFormat($object);
             $this->sizeBytes = MagickGetImageSize($object);
             $this->compression = MagickGetImageCompression($object);
             $this->compressionQuality = MagickGetImageCompressionQuality($object);
             $this->resolution = MagickGetImageResolution($object);
             $this->resolutionUnits = MagickGetImageUnits($object);
         } catch (Exception $e) {
             throw new Exception('Ocorreu um erro!');
         }
     } else {
         throw new Exception('O arquivo está ausente!');
     }
     return $this;
 }
Example #2
0
 /**
  * 返回图片大小
  */
 public function getSize()
 {
     return MagickGetImageSize(self::$resource);
 }