Beispiel #1
0
 /**
  * @return Image
  */
 private function createImage()
 {
     $image = new Image();
     $image->setFilename('silvestra.png');
     $image->setOriginalPath($this->filesystem->getRelativeFilePath($image->getFilename()));
     $this->symfonyFilesystem->copy(dirname(__FILE__) . '/../../Fixtures/silvestra.png', $this->filesystem->getActualFileDir($image->getFilename()) . '/' . $image->getFilename());
     return $image;
 }
Beispiel #2
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);
 }
Beispiel #3
0
 /**
  * Create image.
  *
  * @param UploadedFile $uploadedImage
  *
  * @return ImageInterface
  */
 public function createImage(UploadedFile $uploadedImage)
 {
     $image = $this->imageManager->create();
     $filename = $this->getUniqueFilename($uploadedImage);
     $image->setFilename($filename);
     $image->setMimeType($uploadedImage->getClientMimeType());
     $image->setOrderNr(1);
     $image->setOriginalPath($this->filesystem->getRelativeFilePath($filename));
     $image->setPath($image->getOriginalPath());
     $image->setSize($uploadedImage->getClientSize());
     $image->setTemporary(true);
     $this->imageManager->add($image);
     $fileDir = $this->filesystem->getActualFileDir($filename);
     $uploadedImage->move($fileDir, $image->getFilename());
     return $image;
 }
Beispiel #4
0
 /**
  * Test method: mkdir() with empty filename.
  */
 public function testMkdir()
 {
     $dir = $this->filesystem->getActualFileDir('silvestra.png');
     $this->filesystem->mkdir($dir);
     $this->assertFileExists($dir);
 }