Decode GIF into array of data for easy use in PHP userland.
public decode ( GifByteStream $bytes ) : array | ||
$bytes | GifByteStream | Decode byte stream into array of GIF blocks. |
return | array | Array containing GIF data |
/** * Load a GIF image. * * @param string $imageFile * * @return Image * @throws \Exception */ private static function _createGif($imageFile) { $gift = new GifHelper(); $bytes = $gift->open($imageFile); $animated = $gift->isAnimated($bytes); $blocks = ''; if ($animated) { $blocks = $gift->decode($bytes); } $gd = @imagecreatefromgif($imageFile); if (!$gd) { throw new \Exception(sprintf('Could not open "%s". Not a valid %s file.', $imageFile, ImageType::GIF)); } return new self($gd, $imageFile, imagesx($gd), imagesy($gd), ImageType::GIF, $blocks, $animated); }