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; } } } }
public function process(Version $version) { switch ($this->getFormat()) { case self::FORMAT_JPEG: $extension = 'jpg'; default: $extension = 'jpg'; break; } if ($extension) { $fr = $version->getFileResource(); $image = \Image::load($fr->read()); $filename = $version->getFileName(); $service = \Core::make('helper/file'); $newFilename = $service->replaceExtension($filename, $extension); $version->updateContents($image->get($extension)); $version->rename($newFilename); } }
/** * {@inheritDoc} */ public function updateContents($contents) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'updateContents', array($contents)); return parent::updateContents($contents); }
public function process(Version $version) { $fr = $version->getFileResource(); $image = \Image::load($fr->read()); $version->updateContents($image->get('jpg', array('jpeg_quality' => $this->getQuality()))); }
public function updateContents($contents) { return parent::updateContents($contents); }
public function process(Version $version) { $fr = $version->getFileResource(); $image = \Image::load($fr->read()); $fr = $version->getFileResource(); $width = $this->getMaxWidth(); $height = $this->getMaxHeight(); $mode = $this->getConstraintMode(); $thumbnail = $image->thumbnail(new Box($width, $height), $mode); $mimetype = $fr->getMimeType(); $thumbnailOptions = array(); switch ($mimetype) { case 'image/jpeg': $thumbnailType = 'jpeg'; $thumbnailOptions = array('jpeg_quality' => \Config::get('concrete.misc.default_jpeg_image_compression')); break; case 'image/png': $thumbnailType = 'png'; break; case 'image/gif': $thumbnailType = 'gif'; break; case 'image/xbm': $thumbnailType = 'xbm'; break; case 'image/vnd.wap.wbmp': $thumbnailType = 'wbmp'; break; default: $thumbnailType = 'png'; break; } $version->updateContents($thumbnail->get($thumbnailType, $thumbnailOptions)); }