Exemple #1
0
 public function inspect(Version $fv)
 {
     $fr = $fv->getFileResource();
     $image = Image::load($fr->read());
     $data = $image->getSize();
     // sets an attribute - these file attribute keys should be added
     // by the system and "reserved"
     $at1 = FileAttributeKey::getByHandle('width');
     $at2 = FileAttributeKey::getByHandle('height');
     $fv->setAttribute($at1, $data->getWidth());
     $fv->setAttribute($at2, $data->getHeight());
 }
Exemple #2
0
 public function inspect(Version $fv)
 {
     $fr = $fv->getFileResource();
     $imagine = Core::make(Image::getFacadeAccessor());
     if (\Config::get('concrete.file_manager.images.use_exim_data_to_rotate_images')) {
         try {
             $imagine->setMetadataReader(new ExifMetadataReader());
         } catch (NotSupportedException $e) {
         }
     }
     $image = $imagine->load($fr->read());
     $data = $image->getSize();
     // sets an attribute - these file attribute keys should be added
     // by the system and "reserved"
     $at1 = FileAttributeKey::getByHandle('width');
     $at2 = FileAttributeKey::getByHandle('height');
     $fv->setAttribute($at1, $data->getWidth());
     $fv->setAttribute($at2, $data->getHeight());
     // Set image aspect ratio if we can.
     \Log::info('Image Inspector');
     if (\Config::get('concrete.file_manager.images.use_exim_data_to_rotate_images')) {
         $metadata = $image->metadata();
         \Log::info('Checking EXIF Metadata');
         if (isset($metadata['ifd0.Orientation'])) {
             \Log::info('EXIF data found: ' . $metadata['ifd0.Orientation']);
             switch ($metadata['ifd0.Orientation']) {
                 case 3:
                     $image->rotate(180);
                     $fv->updateContents($image->get($fv->getExtension()));
                     break;
                 case 6:
                     $image->rotate(90);
                     $fv->updateContents($image->get($fv->getExtension()));
                     break;
                 case 8:
                     $image->rotate(-90);
                     $fv->updateContents($image->get($fv->getExtension()));
                     break;
             }
         }
     }
 }
Exemple #3
0
 public function inspect(Version $fv)
 {
     $at1 = FileAttributeKey::getByHandle('duration');
     $at2 = FileAttributeKey::getByHandle('width');
     $at3 = FileAttributeKey::getByHandle('height');
     // we killed $path here because the file might be hosted remotely.
     // @TODO add in support for streams through the $filesystem object.
     $cf = Core::make('helper/concrete/file');
     $fs = $fv->getFile()->getFileStorageLocationObject()->getFileSystemObject();
     $fp = $fs->readStream($cf->prefix($fv->getPrefix(), $fv->getFileName()));
     @fseek($fp, 27);
     $onMetaData = fread($fp, 10);
     //if ($onMetaData != 'onMetaData') exit('No meta data available in this file! Fix it using this tool: http://www.buraks.com/flvmdi/');
     @fseek($fp, 16, SEEK_CUR);
     $duration = array_shift(unpack('d', strrev(fread($fp, 8))));
     @fseek($fp, 8, SEEK_CUR);
     $width = array_shift(unpack('d', strrev(fread($fp, 8))));
     @fseek($fp, 9, SEEK_CUR);
     $height = array_shift(unpack('d', strrev(fread($fp, 8))));
     $fv->setAttribute($at1, $duration);
     $fv->setAttribute($at2, $width);
     $fv->setAttribute($at3, $height);
 }
 /**
  * {@inheritDoc}
  */
 public function setAttribute($ak, $value)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setAttribute', array($ak, $value));
     return parent::setAttribute($ak, $value);
 }
 public function setAttribute($ak, $value)
 {
     return parent::setAttribute($ak, $value);
 }