Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function animate($format, $delay, $loops)
 {
     if ('gif' !== strtolower($format)) {
         throw new NotSupportedException('Animated picture is currently only supported on gif');
     }
     if (!is_int($loops) || $loops < 0) {
         throw new InvalidArgumentException('Loops must be a positive integer.');
     }
     if (null !== $delay && (!is_int($delay) || $delay < 0)) {
         throw new InvalidArgumentException('Delay must be either null or a positive integer.');
     }
     try {
         foreach ($this as $offset => $layer) {
             $this->resource->setimageindex($offset);
             $this->resource->setimageformat($format);
             if (null !== $delay) {
                 $this->resource->setimagedelay($delay / 10);
             }
             $this->resource->setimageiterations($loops);
         }
     } catch (\GmagickException $e) {
         throw new RuntimeException('Failed to animate layers', $e->getCode(), $e);
     }
     return $this;
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function animate($format, $delay, $loops)
 {
     if ('gif' !== strtolower($format)) {
         throw new InvalidArgumentException('Animated picture is currently only supported on gif');
     }
     foreach (array('Loops' => $loops, 'Delay' => $delay) as $name => $value) {
         if (!is_int($value) || $value < 0) {
             throw new InvalidArgumentException(sprintf('%s must be a positive integer.', $name));
         }
     }
     try {
         foreach ($this as $offset => $layer) {
             $this->resource->setimageindex($offset);
             $this->resource->setimageformat($format);
             $this->resource->setimagedelay($delay / 10);
             $this->resource->setimageiterations($loops);
         }
     } catch (\GmagickException $e) {
         throw new RuntimeException('Failed to animate layers', $e->getCode(), $e);
     }
     return $this;
 }