feat: migrate label rendering from sharp to resvg for improved SVG support
Build and Push Multi-Platform Images / build-and-push (push) Successful in 41s

This commit is contained in:
2026-05-08 09:05:05 +02:00
parent 45c371a60d
commit 658c6de74e
3 changed files with 220 additions and 2 deletions
@@ -1,6 +1,6 @@
import { Injectable, Logger } from '@nestjs/common';
import * as QRCode from 'qrcode';
import sharp from 'sharp';
import { Resvg } from '@resvg/resvg-js';
import type { LabelElement } from '../database/entities/barcode-template.entity';
const MM_TO_PX = 300 / 25.4; // 300 DPI
@@ -89,6 +89,7 @@ export class LabelRendererService {
${parts.join('\n ')}
</svg>`;
return sharp(Buffer.from(svg)).png().toBuffer();
const resvg = new Resvg(svg, { font: { loadSystemFonts: true } });
return Buffer.from(resvg.render().asPng());
}
}