image
image copied to clipboard
¿Animated GIF support?
Hello, I was wondering to know if it is possible to get and save an animated GIF, since when I try:
Image::make('mygif.gif')->save('images/mygif.gif);
It will become a "static" image, losing the animation.
Thanks in advance
It's not possible at the moment, but would be nice to have.
I also wanted this feature.
For now, you can use another function to save when it is a gif, and keep using others from the library.
$image = Image::make($file->getRealPath());
if ($file->getClientOriginalExtension() == 'gif') {
copy($file->getRealPath(), $destination);
}
else {
$image->save($destination);
}
$width = $image->width();
$height = $image->height();
$image->destroy();
A great suggestion. At the moment I'm just copying the resource, but it'll be great to be able to crop an animated gif.
As I understand this feature is already present in development branch. (I've forked repo and merged master into development and checked this functionality in laravel app I'm currently working on) @olivervogel can you comment on when you plan to release it. I see tag nextversion on this issue but not sure what it exactly means.
The development branch represents what will be the next major version (3.x). But it is currently under development and I would not use the branch for anything than development at all. Tag nextversion means that this feature will be available in the next major version.
Currently there is no release date. This is a free open source project and I'm working on it in my spare time.
@olivervogel thanks for clarification
What is the current status here?
make sure to use strtolower() on getClientOriginalExtension() as some images may have different casing on file extensions.
https://github.com/glukash/glu-image
support only laravel 4
need laravel 5.2 help me please
system("convert big.gif -coalesce coalesce.gif"); system("convert -size 200x100 coalesce.gif -resize 200x10 small.gif");
Keep GIF animation for Imagick:
$im = new \Imagick('path/to;image');
if ($im->getImageFormat() == 'GIF') {
$im = $im->coalesceImages();
do {
$im->resizeImage($resize['width'], $resize['height'], \Imagick::FILTER_BOX, 1);
} while ($im->nextImage());
$im = $im->deconstructImages();
} else {
$im->resizeImage($resize['width'], $resize['height'], \Imagick::FILTER_LANCZOS, 1, true);
}
$im->writeImages('some/path/to', true)
For GD check animation:
function is_animated($filename)
$filecontents = file_get_contents($filename);
$str_loc = 0;
$count = 0;
while ($count < 2) { // There is no point in continuing after we find a 2nd frame
$where1 = strpos($filecontents, "\x00\x21\xF9\x04", $str_loc);
if (!$where1) {
break;
} else {
$str_loc = $where1 + 1;
$where2 = strpos($filecontents, "\x00\x2C", $str_loc);
if (!$where2) {
break;
} else {
if ($where1 + 8 == $where2) {
++$count;
}
$str_loc = $where2 + 1;
}
}
}
return $count > 1;
}
Maybe can help on slipt a GIF image: http://stackoverflow.com/a/12553165/4367683
More info: http://stackoverflow.com/a/718500/4367683
For animated GIFs, the Lib should split them before each method calls and iterates the frames, doing the action foreach one.
Any News?
Any update for animated GIFs,?
Still gif images are not supported
Perhaps make a pull request to help them out, if this is so important?
Up
Yeah i'm in too.
The code a pasted above is not usefull?
Thanks, it's usefull!
Image GD class that supports GIF manipulation: https://gist.github.com/odahcam/e7255f406e02ddf390080bf3add2cd43#file-imagegd-php-L4
Any plans for this? Gifs are a big part of the web these days...
Any update on this? :)
@olivervogel You mention above a development branch, but I can't seem to find it anywhere. Is it public? If so, where might one find it? And of course, thanks for this great package!
Thanks @marcoflorian
I am interested in this one as well. I see only the first frame is captured on resize, so for now will just copy GIF resources.
@olivervogel, I know this is ancient, but are you still able to link to the development code that was referenced above? I'm not seeing anything anymore except for a master and a 1.6 branch in this repository. I'm asking because I'd like to potentially expand upon what's already built, if possible (since I need this for something I'm working on and may need to move to intervention/image myself in the future, i.e. SilverStripe v4). So, if we can incorporate this as core functionality (at least with Imagick) I may be interested.
For what it's worth: This is the first time I've looked at intervention/image. However, digging deeper into how this would work in Imagick at least, I think this has probably lagged behind a bit, since working with an animated gif seems to require that you basically iterate over every single frame as it's own separate instance of Imagick (a child of the parent instance) and then and apply the defined transformations repeatedly (e.g. ->resize(), ->resizeCanvas(), ->fit() and etc.) before being merged back together as a single image (i.e. the final encoded blob/file, per the internal API). I'm not sure how this would be accomplished internally within this library, but I could see how that might require yet another layer of abstraction/complexity. For example, maybe one could ensure that if this is an animated gif (e.g. Imagick->count() > 0) you would wrap the execution of commands in an iteration that would be called on a cached result of Imagick->coalesceImages(). I don't know; I haven't actually used this library yet, but I will someday 😄.
Still interested in animated gif support, this package is almost perfect, the lack of gif support does hurt though!
Still interested in animated gif support, this package is almost perfect, the lack of gif support does hurt though!
As previous fella. :)
How is this still not a thing?
Is anybody actively working on this? Has there been any work done on this? Is there a branch that I could pick up? What's stopping it? Complexity and/or lack of developer motivation? Technical hurdles?