Skip to content

Instantly share code, notes, and snippets.

@uditalias
Created February 24, 2019 18:49
Show Gist options
  • Save uditalias/8f3bb2e1a35ee0cc34c18adc9b937c1d to your computer and use it in GitHub Desktop.
Save uditalias/8f3bb2e1a35ee0cc34c18adc9b937c1d to your computer and use it in GitHub Desktop.
protected async _render(): Promise<sharp.Sharp> {
const languages = this.hydrateRendererLanguages()
, totalLanguages = languages.length
, [width, height] = this.calculateCanvasSize(totalLanguages)
, destWidth = width * this.options.scale
, destHeight = height * this.options.scale
, dpi = DEFAULT_DPI * destWidth / width
, svg = Buffer.from(handlebars.compile(SOLID_TEMPLATE)({ languages, width, height }));
return sharp(svg, { density: dpi })
.resize(destWidth, destHeight);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment