public function testIsAnimated()
 {
     $encoder = new Encoder();
     $this->assertFalse($encoder->isAnimated());
     $encoder->addFrame(Mockery::mock('Intervention\\Gif\\Frame'));
     $this->assertFalse($encoder->isAnimated());
     $encoder->addFrame(Mockery::mock('Intervention\\Gif\\Frame'));
     $this->assertTrue($encoder->isAnimated());
 }
Exemple #2
0
 /**
  * Processes and returns encoded image as GIF string
  *
  * @return string
  */
 protected function processGif()
 {
     $image = $this->image;
     $encoder = new GifEncoder();
     $encoder->setCanvas($image->getWidth(), $image->getHeight());
     $encoder->setLoops($image->getContainer()->getLoops());
     // set frames
     foreach ($image as $frame) {
         // extract each frame
         ob_start();
         imagegif($frame->getCore());
         $frame_data = ob_get_contents();
         ob_end_clean();
         // decode frame
         $decoder = new GifDecoder();
         $decoder->initFromData($frame_data);
         $decoded = $decoder->decode();
         // add each frame
         $encoder->addFrame($decoded->getFrame()->setLocalColorTable($decoded->getGlobalColorTable())->setDelay($frame->delay));
     }
     return $encoder->encode();
 }