import { IRasterizer , RasterizerOutputFormat } from '@swirly/types' ; import execa from 'execa' ; export class InkscapeRasterizer implements IRasterizer { async init ( ) { } async dispose ( ) { } async rasterize ( svgXml , width , height , format ) { if ( format !== 'png' ) { throw new Error ( 'Output type must be "png"' ) ; } const cmd = 'inkscape' ; const args = [ '--pipe' , '--export-type' , format , '--export-width' , String ( width ) , '--export-height' , String ( height ) ] ; const options = { encoding : null , input : svgXml , stdin : undefined , sderr : undefined } ; const { stdout } = await execa ( cmd , args , options ) ; return stdout ; } }