Пример #1
0
 /**
  * @param array  $options
  * @param string $path
  */
 private function prepareOutput(array $options, $path = null)
 {
     if (isset($options['format'])) {
         $this->imagick->setImageFormat($options['format']);
     }
     if (isset($options['animated']) && true === $options['animated']) {
         $format = isset($options['format']) ? $options['format'] : 'gif';
         $delay = isset($options['animated.delay']) ? $options['animated.delay'] : null;
         $loops = 0;
         if (isset($options['animated.loops'])) {
             $loops = $options['animated.loops'];
         } else {
             // Calculating animated GIF iterations is a crap-shoot: https://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=23276
             // Looks like it started working around 6.8.8-3: http://git.imagemagick.org/repos/ImageMagick/blob/a01518e08c840577cabd7d3ff291a9ba735f7276/ChangeLog#L914-916
             $versionInfo = $this->imagick->getVersion();
             if (isset($versionInfo['versionString'])) {
                 preg_match('/ImageMagick ([0-9]+\\.[0-9]+\\.[0-9]+-[0-9])/', $versionInfo['versionString'], $versionInfo);
                 if (isset($versionInfo[1])) {
                     if (version_compare($versionInfo[1], '6.8.8-3', '>=')) {
                         $loops = $this->imagick->getImageIterations();
                     }
                 }
             }
         }
         $options['flatten'] = false;
         $this->layers->animate($format, $delay, $loops);
     } else {
         $this->layers->merge();
     }
     $this->applyImageOptions($this->imagick, $options, $path);
     // flatten only if image has multiple layers
     if ((!isset($options['flatten']) || $options['flatten'] === true) && count($this->layers) > 1) {
         $this->flatten();
     }
 }
Пример #2
0
 /**
  * @param array  $options
  * @param string $path
  */
 private function prepareOutput(array $options, $path = null)
 {
     if (isset($options['format'])) {
         $this->imagick->setImageFormat($options['format']);
     }
     if (isset($options['animated']) && true === $options['animated']) {
         $format = isset($options['format']) ? $options['format'] : 'gif';
         $delay = isset($options['animated.delay']) ? $options['animated.delay'] : null;
         $loops = isset($options['animated.loops']) ? $options['animated.loops'] : 0;
         $options['flatten'] = false;
         $this->layers->animate($format, $delay, $loops);
     } else {
         $this->layers->merge();
     }
     $this->applyImageOptions($this->imagick, $options, $path);
     // flatten only if image has multiple layers
     if ((!isset($options['flatten']) || $options['flatten'] === true) && count($this->layers) > 1) {
         $this->flatten();
     }
 }