Пример #1
0
 /**
  * Update the focus after update.
  *
  * @param MediaInterface $media
  */
 public function updateFocus(MediaInterface $media)
 {
     if ($this->angle == 90) {
         $focusLeft = 100 - $media->getFocusTop();
         $focusTop = $media->getFocusLeft();
     } elseif ($this->angle == -90) {
         $focusLeft = $media->getFocusTop();
         $focusTop = 100 - $media->getFocusLeft();
     }
     $media->setFocusLeft($focusLeft);
     $media->setFocusTop($focusTop);
 }
Пример #2
0
 /**
  * Update the focus after update.
  *
  * @param MediaInterface $media
  */
 public function updateFocus(MediaInterface $media)
 {
     if ($this->direction == 'x') {
         $media->setFocusLeft(100 - $media->getFocusLeft());
     } elseif ($this->direction == 'y') {
         $media->setFocusTop(100 - $media->getFocusTop());
     }
 }
Пример #3
0
 /**
  * Update the focus after update.
  *
  * @param MediaInterface $media
  */
 public function updateFocus(MediaInterface $media)
 {
     $originalFocusLeftPx = $media->getFocusLeft() * $media->getWidth() / 100;
     $newFocusLeftPx = $originalFocusLeftPx - $this->x;
     $newFocusLeft = $newFocusLeftPx * 100 / $this->w;
     if ($newFocusLeft < 0) {
         $newFocusLeft = 0;
     }
     if ($newFocusLeft > 100) {
         $newFocusLeft = 100;
     }
     $media->setFocusLeft($newFocusLeft);
     $originalFocusTopPx = $media->getFocusTop() * $media->getHeight() / 100;
     $newFocusTopPx = $originalFocusTopPx - $this->y;
     $newFocusTop = $newFocusTopPx * 100 / $this->h;
     if ($newFocusTop < 0) {
         $newFocusTop = 0;
     }
     if ($newFocusTop > 100) {
         $newFocusTop = 100;
     }
     $media->setFocusTop($newFocusTop);
 }
Пример #4
0
 /**
  * Crop image if is not exists in alias.
  *
  * @param MediaInterface   $media
  * @param AliasManipulator $aliasManipulator
  */
 private function cropImage(MediaInterface $media, AliasManipulator $aliasManipulator)
 {
     $aliasName = $aliasManipulator->getAliasName();
     $aliasArray = $aliasManipulator->getAliasArray();
     $mediaPath = $aliasName . '/' . $media->getReference();
     if ($this->filesystemManipulator->has($mediaPath)) {
         return true;
     }
     $mediaOriginalPath = $this->originalDir . '/' . $media->getReference();
     if (!$this->filesystemManipulator->has($mediaOriginalPath)) {
         throw new \Exception('The file \'' . $mediaOriginalPath . '\' is not found.');
     }
     if ($aliasArray['focus'] === true) {
         $magicFocus = new Focus($this, $media);
         $magicFocus->setTargetSize($aliasArray['width'], $aliasArray['height'])->setFocus($media->getFocusLeft(), $media->getFocusTop())->apply($aliasName);
         return true;
     }
     $resize = new Resize($this, $media);
     $resize->setTargetSize($aliasArray['width'], $aliasArray['height'])->apply($aliasName);
     return true;
 }