Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function current()
 {
     if (!isset($this->layers[$this->offset])) {
         try {
             $this->resource->setimageindex($this->offset);
             $this->layers[$this->offset] = $this->resource->getimage();
         } catch (\GmagickException $e) {
             throw new RuntimeException(sprintf('Failed to extract layer %d', $this->offset), $e->getCode(), $e);
         }
     }
     return new Image($this->layers[$this->offset]);
 }
Пример #2
0
 /**
  * Tries to extract layer at given offset
  *
  * @param  integer          $offset
  * @return Image
  * @throws RuntimeException
  */
 private function extractAt($offset)
 {
     if (!isset($this->layers[$offset])) {
         try {
             $this->resource->setimageindex($offset);
             $this->layers[$offset] = new Image($this->resource->getimage(), $this->palette, new MetadataBag());
         } catch (\GmagickException $e) {
             throw new RuntimeException(sprintf('Failed to extract layer %d', $offset), $e->getCode(), $e);
         }
     }
     return $this->layers[$offset];
 }