Exemplo n.º 1
0
 /**
  * Removes all frames of an animation except one
  *
  * @param  \Intervention\Image\Image $image
  * @return boolean
  */
 public function execute($image)
 {
     $keepIndex = $this->argument(0)->type('int')->value(0);
     $container = new Container();
     $container->add($image->getCore($keepIndex));
     $image->setContainer($container);
     return true;
 }
Exemplo n.º 2
0
 public function testIterateToFrames()
 {
     $frame = Mockery::mock('Intervention\\Image\\Frame');
     $container = new Container();
     $container->addFrame($frame);
     $container->addFrame($frame);
     foreach ($container as $key => $value) {
         $this->assertInstanceOf('Intervention\\Image\\Frame', $value);
     }
 }
Exemplo n.º 3
0
 /**
  * Initiates new image from binary data
  *
  * @param  string $data
  * @return \Intervention\Image\Image
  */
 public function initFromBinary($binary)
 {
     try {
         // try to custom decode gif
         $gifDecoder = new GifDecoder();
         $decoded = $gifDecoder->initFromData($binary)->decode();
         // create image
         $container = Container::initFromDecoded($decoded);
         $image = $this->initFromContainer($container);
         $image->mime = 'image/gif';
     } catch (\Exception $e) {
         $resource = @imagecreatefromstring($binary);
         if ($resource === false) {
             throw new \Intervention\Image\Exception\NotReadableException("Unable to init from given binary data.");
         }
         // create image
         $image = $this->initFromGdResource($resource);
         $image->mime = finfo_buffer(finfo_open(FILEINFO_MIME_TYPE), $binary);
     }
     return $image;
 }
Exemplo n.º 4
0
 /**
  * Builds new container from GD resource
  *
  * @param  resource $resource
  * @return \Intervention\Image\Gd\Container
  */
 public function newContainer($resource)
 {
     $container = new Container();
     $container->setFrames(array(new Frame($resource)));
     return $container;
 }