in lib/transform-rule.js [31:57]
transformToPNG(file) {
const { path } = file;
const normalizedContent = normalizeSVG(file.content);
return sharp(Buffer.from(normalizedContent))
.resize({
width: this.width - this.paddingH * 2,
height: this.height,
fit: 'contain',
background: {r: 0, g: 0, b: 0, alpha: 0}
})
.extend({
right: this.paddingH,
left: this.paddingH,
background: {r: 0, g: 0, b: 0, alpha: 0}
})
.png()
.toBuffer({resolveWithObject: true})
.then(({data, info}) => {
if (info.width !== this.width || info.height !== this.height) {
console.error('Error details', this.options, file.filename, info);
throw new Error('Resulting Image size is not equal to rule size');
}
const newFilepath = path.replace(/\.svg$/, '.png');
return new File(newFilepath, data);
});
}