toBuffer({ type, canvas, quality = 70 }) {
    quality = quality >> 0;
    quality = Math.min(quality, 100);
    let compressionLevel = 10 - 0.1 * quality;
    compressionLevel = compressionLevel >> 0;

    let buffer;
    switch (type) {
      case 'png':
      case 'gif':
        buffer = canvas.toBuffer('image/png', {
          compressionLevel,
          filters: canvas.PNG_FILTER_NONE,
        });
        break;

      case 'jpg':
      case 'jpeg':
        buffer = canvas.toBuffer('image/jpeg', { quality: quality / 100 });
        break;

      default:
        buffer = canvas.toBuffer('raw');
        break;
    }

    return buffer;
  }
Utility function to get buffer
@param {string} type - picture format type
@param {Canvas} canvas - Container canvas
@param {number} quality - picture quality
@return {buffer} The returned buffer value
@public