/**
* 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);
}