コード例 #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;
     }
 }
コード例 #2
0
 /**
  * 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;
 }