예제 #1
0
 /**
  * @covers \Magento\Framework\View\Design\Theme\Image::createPreviewImage
  */
 public function testCreatePreviewImage()
 {
     $this->_themeMock->setData($this->_getThemeSampleData());
     $this->_themeMock->setData('preview_image', null);
     $this->_imageMock->expects($this->once())->method('save')->with('/media_path/theme/preview', $this->anything());
     $this->_model->createPreviewImage('/some/path/to/image.png');
     $this->assertNotNull($this->_themeMock->getData('preview_image'));
 }
예제 #2
0
 /**
  * @return MagentoImage
  */
 public function getImageProcessor()
 {
     if (!$this->_processor) {
         $filename = $this->getBaseFile() ? $this->_mediaDirectory->getAbsolutePath($this->getBaseFile()) : null;
         $this->_processor = $this->_imageFactory->create($filename);
     }
     $this->_processor->keepAspectRatio($this->_keepAspectRatio);
     $this->_processor->keepFrame($this->_keepFrame);
     $this->_processor->keepTransparency($this->_keepTransparency);
     $this->_processor->constrainOnly($this->_constrainOnly);
     $this->_processor->backgroundColor($this->_backgroundColor);
     $this->_processor->quality($this->_quality);
     return $this->_processor;
 }
예제 #3
0
파일: Image.php 프로젝트: swnsma/practice
 public function save($destination = null, $newName = null)
 {
     $this->_processor->save($destination, $newName);
 }
예제 #4
0
 /**
  * Setup base image properties for resize
  *
  * @param \Magento\Framework\Image $image
  * @param bool $isSwatch
  * @return $this
  */
 protected function setupImageProperties(\Magento\Framework\Image $image, $isSwatch = false)
 {
     $image->quality(100);
     $image->constrainOnly(true);
     $image->keepAspectRatio(true);
     if ($isSwatch) {
         $image->keepFrame(true);
         $image->keepTransparency(true);
         $image->backgroundColor('#FFF');
     }
     return $this;
 }
예제 #5
0
 /**
  * Image Processor
  *
  * @return \Magento\Framework\Image
  */
 public function getImageProcessor()
 {
     if (!$this->processor) {
         $filename = $this->getBaseFile();
         $this->processor = $this->imageFactory->create($filename);
     }
     $this->processor->keepAspectRatio(true);
     $this->processor->keepFrame($this->keepFrame);
     $this->processor->keepTransparency($this->keepTransparency);
     $this->processor->constrainOnly($this->constrainOnly);
     $this->processor->backgroundColor($this->backgroundColor);
     $this->processor->quality($this->quality);
     return $this->processor;
 }