コード例 #1
1
 public function setFile($file)
 {
     $this->file = $file;
     $this->image = Image::make($this->file);
     $this->iptc = $this->image->iptc();
     $this->exif = $this->image->exif();
     return $this;
 }
コード例 #2
1
ファイル: OrientateCommand.php プロジェクト: hilmysyarif/sic
 /**
  * Correct image orientation according to Exif data
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     switch ($image->exif('Orientation')) {
         case 2:
             $image->flip();
             break;
         case 3:
             $image->rotate(180);
             break;
         case 4:
             $image->rotate(180)->flip();
             break;
         case 5:
             $image->rotate(270)->flip();
             break;
         case 6:
             $image->rotate(270);
             break;
         case 7:
             $image->rotate(90)->flip();
             break;
         case 8:
             $image->rotate(90);
             break;
     }
     return true;
 }
コード例 #3
1
ファイル: Exif.php プロジェクト: Tirme/blog
 public function height(Image $image)
 {
     $exif = $image->exif();
     $height = isset($exif['ExifImageLength']) ? $exif['ExifImageLength'] : '';
     return $height;
 }
コード例 #4
1
ファイル: _ide_helper.php プロジェクト: jorzhikgit/MLM-Nexus
 /**
  * Read Exif data from the current image
  * 
  * Note: Windows PHP Users - in order to use this method you will need to
  * 
  * enable the mbstring and exif extensions within the php.ini file.
  *
  * @param string $key
  * @return mixed 
  * @static 
  */
 public static function exif($key = null)
 {
     return \Intervention\Image\Image::exif($key);
 }
コード例 #5
1
 public function process()
 {
     $data = $this->loadData();
     if ($data !== true) {
         return $this->failure($data);
     }
     $mobile = (int) $this->getProperty('mobile', 0);
     if ($mobile == 1) {
         $orientation = $this->img->exif('Orientation');
         switch ($orientation) {
             case 3:
                 $this->img->rotate(180);
                 break;
             case 6:
                 $this->img->rotate(-90);
                 break;
             case 8:
                 $this->img->rotate(90);
                 break;
         }
     }
     if (isset($this->data['rotate'])) {
         $rotate = $this->data['rotate'] * -1.0;
         $this->img->rotate($rotate);
     }
     $crop = $this->getProperty('crop', 0);
     if ($crop == 1 && isset($this->data['width']) && isset($this->data['height'])) {
         $width = intval($this->data['width']);
         $height = intval($this->data['height']);
         if ($height != 0 && $width != 0) {
             $this->img->crop($width, $height, intval($this->data['x']), intval($this->data['y']));
         }
     }
     $fileName = $this->generateUniqueFileName();
     $width = (int) $this->md->getOption('resizer.width', null, 0);
     $width = empty($width) ? null : $width;
     $height = (int) $this->md->getOption('resizer.height', null, 0);
     $height = empty($height) ? null : $height;
     $profileName = $this->getProperty('profile', '');
     if (!empty($profileName) && $crop == 1) {
         $profiles = $this->modx->fromJSON($this->md->getOption('cropper.profiles', null, '[]'));
         foreach ($profiles as $profile) {
             if (!isset($profile['name']) || $profile['name'] != $profileName) {
                 continue;
             }
             $profileWidth = (int) $profile['width'];
             $profileHeight = (int) $profile['height'];
             $width = empty($profileWidth) ? $width : $profileWidth;
             $height = empty($profileHeight) ? $height : $profileHeight;
             break;
         }
     }
     if ($width != null || $height != null) {
         $this->img->resize($width, $height, function ($constraint) {
             /** @var \Intervention\Image\Constraint $constraint */
             $constraint->aspectRatio();
             $constraint->upsize();
         });
     }
     $this->img->save($this->uploadPath . $fileName . '.' . $this->extension);
     return $this->success('', array('path' => $this->uploadURL . $fileName . '.' . $this->extension, 'name' => $this->originalName));
 }