stil / gif-endec

PHP GIF encoder and decoder
63 stars 16 forks source link

how to get frame count? #11

Open khstar2000 opened 6 years ago

khstar2000 commented 6 years ago

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?

ghost commented 5 years ago

Upd: This is the best solution, which i have found:

<?php
function FrameCount($File){

if(is_file($File)) $File = file_get_contents($File);
return abs(substr_count($File, "\x21\xf9")-substr_count($File,"\x21\xfe")-2);

}