public function thumbnail($pathToImage, $width, $height)
 {
     try {
         $this->openImage = $this->imagine->open(FileHelper::normalizePath($pathToImage))->thumbnail(new \Imagine\Image\Box($width, $height));
     } catch (\Exception $ex) {
         \Codeception\Util\Debug::debug($ex->getMessage());
     }
 }
 /**
  * Get the image in a $type size.
  * @param string $category image category
  * @param string $type image type. Example 'thumb'
  * @param string $name image name
  * @return bool|string return name or false if image not exist
  */
 public function get($category, $type, $name)
 {
     /* Get the path to the folder with the images. */
     $directory = \Yii::getAlias($this->owner->imagesPath);
     $imagePath = implode(DIRECTORY_SEPARATOR, [$directory, $category]);
     $images = glob($imagePath . DIRECTORY_SEPARATOR . "{$name}-{$type}.*");
     if ($images === false) {
         return false;
     }
     /* Get the first matched file. */
     $image = $images[0];
     return FileHelper::normalizePath($image);
 }
 public function testImagableGet()
 {
     $nameClass = new CRC32Name();
     $imagable = \Yii::createObject(['class' => 'bl\\imagable\\Imagable', 'imagesPath' => '@tests/_data/images', 'nameClass' => $nameClass->className(), 'imageClass' => 'bl\\imagable\\instances\\CreateImageImagine']);
     //image name
     $name = 'testImage';
     $name = $nameClass->getName($name);
     $path =& $this->path;
     $pathToGalery = implode(DIRECTORY_SEPARATOR, [$path, 'galery']);
     $pathToGalery = FileHelper::normalizePath(\Yii::getAlias($pathToGalery));
     //return full path. Example: /var/www/site/images/galery/5cc22de8-small.jpg
     $this->assertEquals($imagable->get('galery', 'small', $name), $pathToGalery . \DIRECTORY_SEPARATOR . $name . '-small.jpg');
     //return full path. Example: /var/www/site/images/galery/5cc22de8-small.jpg
     $this->assertEquals($imagable->getSmall('galery', $name), $pathToGalery . \DIRECTORY_SEPARATOR . $name . '-small.jpg');
     //return full path. Example: /var/www/site/images/galery/5cc22de8-big.jpg
     $stream = null;
     $this->assertEquals($imagable->getBig('galery', $name), $pathToGalery . \DIRECTORY_SEPARATOR . $name . '-big.jpg');
     //        \Codeception\Util\Debug::debug($imagable->getOriginal('galery', $name, $stream));
     //return full path. Example: /var/www/site/images/galery/5cc22de8-original.jpg
     $this->assertEquals($imagable->getOriginal('galery', $name), $pathToGalery . \DIRECTORY_SEPARATOR . $name . '-origin.jpg');
     //return full path. Example: /var/www/site/images/galery/5cc22de8-thumb.jpg
     $this->assertEquals($imagable->getThumb('galery', $name), $pathToGalery . \DIRECTORY_SEPARATOR . $name . '-thumb.jpg');
 }