stil / gif-endec Goto Github PK
View Code? Open in Web Editor NEWPHP GIF encoder and decoder
PHP GIF encoder and decoder
I try to decode the image downloaded from http://icons.wxug.com/i/c/k/clear.gif
it fails. Error I get is "Fatal error: Uncaught Error: Call to a member function setOffset() on null in GIFEndec/Decoder.php:242".
It seems no $this->currentFrame has been created. If I create one "on the fly" in decode() it works.
public function decode(callable $onFrameDecoded)
....
case 0x2C:
if (!$this->currentFrame) {
$this->currentFrame = new Frame();
}
There is a bug here:
Line 183 in 9b9b7d4
See here for correct logic: https://github.com/lunakid/AnimGif/blob/master/src/GifCreator/AnimGif.php#L361
This causes gifs to be corrupted in certain situations
If you load up an animated gif, then substitute the stream of each frame with that of an altered gif file, then re-save, it switches to local color tables (as expected), but it comes out corrupt. Something is wrong about the file format implementation I think, but I don't have time to trace through it.
If I re-save with the same frame streams it works okay. If I hack the code to disable local color table saving it saves okay but with corrupt palette (as expected).
Remove reading first 6 bytes in readHeader():
$this->stream->seek(6); // GIF89a or GIF87a
I want to create a gif, but the use of the library with this framework has been extended to me, is there any experience?
I have added the file package in the code igniter library folder, creating the function intact in this way for example
$ this-> load-> library ('Color');
$ this-> load-> library ('Encoder');
$ this-> load-> library ('Frame');
$ this-> load-> library ('/ IO / FileStream');
But at the time of mail the function throws me
An Error Was Encountered
Non-existent class: Color
Some GIF's give this error when trying to decode. I have attached a broken GIF and a working GIF
Source of error: https://github.com/stil/gif-endec/blob/master/src/Renderer.php#L66-L73
Code Example
$gifStream = new FileStream($uploadedFile);
$gifDecoder = new Decoder($gifStream);
$gifRenderer = new Renderer($gifDecoder);
$gifRenderer->start(function(FrameRenderedEvent $event) use (&$frames) {
$frames[] = $event->renderedFrame;
});
The error from laravel
"message": "Disposal method 3 is not implemented.",
"exception": "RuntimeException",
"file": "C:\\wamp64\\www\\minecraftcapes\\vendor\\stil\\gif-endec\\src\\Renderer.php",
"line": 72,
PHP can be configured how it reads files, regarding \r\n.
MemoryStream.php should always use fopen with 'b' included in the method strings to ensure this doesn't happen.
how to create gif from frames, if frames are in base64 format?
new FileStream(base64img) not working :(
i nedd frame count in render and decorder.
see in following code
$gifStream = new FileStream($target_file);
$gifDecoder = new Decoder($gifStream);
$gifRenderer = new Renderer($gifDecoder);
$gifRenderer->start(function (FrameRenderedEvent $event) {
imagepng($event->renderedFrame, DIR . "/../gif_render/frame{$event->frameIndex}.png");
});
and how to change png filepath and filename(here is gif_render/frame ....png).
then create png, how know png count?
Hello I am having issues with the Decoder giving me the error of 'Call to a member function setOffset() on null'
I am receiving a base64 string from the front end, converting that string to a gif image and then writing that image to a folder. Everything seems to work fine until I hit the Decoder. here is my code below.
public function video(Request $request) {
$date = Carbon::now()->format('m-d-Y');
// split the string on commas
// $data[ 0 ] == "data:image/png;base64"
// $data[ 1 ] == <actual base64 string>
$data = explode( ',', $request->image);
$image = Image::make($data[1])->encode('gif');
$fileName = uniqid() . '.' . 'gif';
$location = 'uploads/' . $fileName;
$image->save($location);
$gifStream = new FileStream($location);
//Create Decoder instance from MemoryStream
$gifDecoder = new Decoder($gifStream);
//Create Renderer instance
$gifRenderer = new Renderer($gifDecoder);
$gifRenderer->start(function (FrameRenderedEvent $event) {
//Convert frame index to zero-padded strings (001, 002, 003)
$paddedIndex = str_pad($event->frameIndex, 3, '0', STR_PAD_LEFT);
// Write frame images to directory
imagepng($event->renderedFrame, "uploads/frame{$paddedIndex}.png");
});
return 'ok';
}
It is creating some really distorted images on few gifs.
Try converting this one:
While if we convert it using https://github.com/Sybio/GifFrameExtractor than there is no problem.
With some images this library does not work. It does not throw any error, but gif image crashes. This happens when first frame has only a few colors (e.g. black and white image or blank one). I ended up by using this lib instead https://github.com/Intervention/gif
Hi!
I installed the GIFEndec because Sybio's Lib made some glitchy pixel salad out of my gif graphics.
When I used your test.gif, everything was fine, but with my gif file:
http://www.nokuku.com/objects/bluebird_l.gif
The code throw this exception:
Uncaught exception 'RuntimeException' with message 'Disposal method 2 is not implemented.'
Please could you help me? Thanks in advance!
Lioba
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.