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';
}
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.