src/Intervention/Gif/Encoder.php
private function buildGraphicsControlExtension(Frame $frame)
    {
        // start
        $extension = "\x21\xF9";
        
        // byte size
        $extension .= "\x04";
        
        // packed field
        $disposalMethod = decbin($frame->getDisposalMethod());
        $disposalMethod = str_pad($disposalMethod, 3, 0, STR_PAD_LEFT);
        $userInputFlat = 0;
        $transparentColorFlag = $frame->hasTransparentColor() ? 1 : 0;
        $packed = $disposalMethod.$userInputFlat.$transparentColorFlag;
        $packed = str_pad($packed, 3, 0, STR_PAD_LEFT);
        $extension .= pack('C', bindec($packed));
        
        // delay
        $extension .= pack('v*', $frame->getDelay());
        
        // transparent color index
        if ($frame->hasTransparentColor()) {
            $extension .= $frame->getTransparentColorIndex();
        } else {
            $extension .= "\x00";
        }
        
        // block terminator
        $extension .= "\x00";

        return $extension;
    }
private function buildGraphicsControlExtension(Frame $frame)
    {
        // start
        $extension = "\x21\xF9";
        
        // byte size
        $extension .= "\x04";
        
        // packed field
        $disposalMethod = decbin($frame->getDisposalMethod());
        $disposalMethod = str_pad($disposalMethod, 3, 0, STR_PAD_LEFT);
        $userInputFlat = 0;
        $transparentColorFlag = $frame->hasTransparentColor() ? 1 : 0;
        $packed = $disposalMethod.$userInputFlat.$transparentColorFlag;
        $packed = str_pad($packed, 3, 0, STR_PAD_LEFT);
        $extension .= pack('C', bindec($packed));
        
        // delay
        $extension .= pack('v*', $frame->getDelay());
        
        // transparent color index
        if ($frame->hasTransparentColor()) {
            $extension .= $frame->getTransparentColorIndex();
        } else {
            $extension .= "\x00";
        }
        
        // block terminator
        $extension .= "\x00";

        return $extension;
    }
Build encoded graphics control extension for frame

@param  Frame  $frame
@return string