Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function crop(ImageInterface $image, array $coordinates)
 {
     $absolutePath = $this->filesystem->getRootDir() . $image->getOriginalPath();
     if (false === file_exists($absolutePath)) {
         throw new NotFoundImageException(sprintf('Not found image in %s', $absolutePath));
     }
     $this->filesystem->mkdir($this->filesystem->getActualFileDir($image->getFilename(), Filesystem::CROPPER_SUB_DIR));
     $imagine = new Imagine();
     $imagine->open($absolutePath)->crop($this->getStartPoint($coordinates['x1'], $coordinates['y1']), $this->getBox($coordinates))->save($this->filesystem->getAbsoluteFilePath($image->getFilename(), Filesystem::CROPPER_SUB_DIR), ImageOptionHelper::getOption($image->getFilename()));
     return $this->filesystem->getRelativeFilePath($image->getFilename(), Filesystem::CROPPER_SUB_DIR);
 }
Exemple #2
0
 public function testGetAbsoluteFilePath()
 {
     $this->assertEquals($this->getMediaRootDir() . '/uploader/s/i/l/v/e/silvestra.png', $this->filesystem->getAbsoluteFilePath('silvestra.png'));
 }