예제 #1
0
 public function transform(ImageInterface $image, ImagineInterface $imagine)
 {
     // Imagine comes with a built-in Autorotate filter, but it seems to be simpler to reimplement it
     // without bothering with the color.
     $metadata = $image->metadata();
     if (!isset($metadata['ifd0.Orientation'])) {
         return;
     }
     $orientation = $metadata['ifd0.Orientation'];
     if ($orientation == 3) {
         $image->rotate(180);
     } elseif ($orientation == 6) {
         $image->rotate(90);
     } elseif ($orientation == 8) {
         $image->rotate(-90);
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  */
 public function apply(ImageInterface $image)
 {
     $metadata = $image->metadata();
     switch (isset($metadata['ifd0.Orientation']) ? $metadata['ifd0.Orientation'] : null) {
         case 3:
             $image->rotate(180, $this->getColor($image));
             break;
         case 6:
             $image->rotate(90, $this->getColor($image));
             break;
         case 8:
             $image->rotate(-90, $this->getColor($image));
             break;
         default:
             break;
     }
     return $image;
 }
예제 #3
0
 /**
  * {@inheritdoc}
  */
 public function apply(ImageInterface $image)
 {
     $metadata = $image->metadata();
     switch (isset($metadata['ifd0.Orientation']) ? $metadata['ifd0.Orientation'] : null) {
         case 1:
             // top-left
             break;
         case 2:
             // top-right
             $image->flipHorizontally();
             break;
         case 3:
             // bottom-right
             $image->rotate(180, $this->getColor($image));
             break;
         case 4:
             // bottom-left
             $image->flipHorizontally();
             $image->rotate(180, $this->getColor($image));
             break;
         case 5:
             // left-top
             $image->flipHorizontally();
             $image->rotate(-90, $this->getColor($image));
             break;
         case 6:
             // right-top
             $image->rotate(90, $this->getColor($image));
             break;
         case 7:
             // right-bottom
             $image->flipHorizontally();
             $image->rotate(90, $this->getColor($image));
             break;
         case 8:
             // left-bottom
             $image->rotate(-90, $this->getColor($image));
             break;
         default:
             // Invalid orientation
             break;
     }
     return $image;
 }
예제 #4
0
 /**
  * @param ImageInterface $file
  * @return bool
  */
 public function isLandscapeOrient(ImageInterface $file)
 {
     $retval = true;
     /** @var MetadataBag $metadata */
     $metadata = $file->metadata();
     $orientation = $metadata->offsetGet('ifd0.Orientation');
     switch ($orientation) {
         case 6:
         case 8:
             $retval = false;
             break;
         default:
             break;
     }
     return $retval;
 }