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
Build and Push Multi-Platform Images / build-and-push (push) Successful in 41s
This commit is contained in:
@@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user