public function createFrameFromGdResource($resource, $delay = null)
    {
        // get imagedata from resource
        $gifdata = $this->encodeGdResource($resource);
        $decoder = new Decoder;
        $gif = $decoder->initFromData($gifdata)->decode();

        $frame = $gif->getFrames()[0];
        $frame->setLocalColorTable($gif->getGlobalColorTable());
        $frame->setDelay($delay);

        $this->frames[] = $frame;
    }