Beispiel #1
0
 /**
  * @param integer $x
  * @param integer $y
  * @param integer $width
  * @param integer $height
  *
  * @return boolean
  */
 public function crop($x, $y, $width, $height)
 {
     try {
         $this->imagick->cropimage($width, $height, $x, $y);
         $this->imagick->writeimage($this->pathToUploadDir . $this->file->getPath());
         $this->file->getParams()->setWidth($width);
         $this->file->getParams()->setHeight($height);
         $this->entityManager->flush();
         return true;
     } catch (\Exception $exception) {
         return false;
     }
 }
 /**
  * Convert file entity to array format
  *
  * @param File $file
  *
  * @return array
  */
 public function convertFileEntityToArray(File $file)
 {
     $params = $file->getParams();
     $directory = $file->getDirectory();
     $fileData = array('id' => $file->getId(), 'dirId' => $directory ? $directory->getId() : 0, 'name' => $file->getName(), 'src' => $file->getPath(), 'mime' => $params->getMime(), 'width' => $params->getWidth(), 'height' => $params->getHeight());
     return $fileData;
 }
 /**
  * @param Directory $directory
  * @param File      $file
  *
  * @return File
  * @throws CopyMoveSelectionException
  */
 private function copyFile(Directory $directory = null, File $file)
 {
     $newFile = clone $file;
     $newFile->setDirectory($directory);
     $newFile->setPath($this->copyFileOnDisk($file->getPath()));
     $this->entityManager->persist($newFile);
     return $newFile;
 }