This commit is contained in:
seb
2026-10-03 13:25:11 +02:00
parent c79ece307c
commit 0d0c5dfdfb
8 changed files with 922 additions and 530 deletions

View File

@@ -69,7 +69,9 @@ export function primaryPrice(article) {
export function priceBrutto(price) {
if (price?.net == null || price?.taxRate == null) return null;
return price.net * (1 + price.taxRate / 100);
const gross = price.net * (1 + price.taxRate / 100);
// Round to cents; epsilon guards float noise (e.g. 9.994999999 vs 9.995).
return Math.round((gross + Number.EPSILON) * 100) / 100;
}
/**

View File

@@ -240,9 +240,14 @@ export function autoCropWhiteAndTransparent(img) {
return canvas;
}
// Crop tightly to bounding box
const cropW = maxX - minX + 1;
const cropH = maxY - minY + 1;
// Restore up to 5 pixels border around the detected content
const PADDING = 5;
const cropX = Math.max(0, minX - PADDING);
const cropY = Math.max(0, minY - PADDING);
const cropMaxX = Math.min(width - 1, maxX + PADDING);
const cropMaxY = Math.min(height - 1, maxY + PADDING);
const cropW = cropMaxX - cropX + 1;
const cropH = cropMaxY - cropY + 1;
const croppedCanvas = document.createElement('canvas');
croppedCanvas.width = cropW;
@@ -253,7 +258,7 @@ export function autoCropWhiteAndTransparent(img) {
return canvas;
}
croppedCtx.drawImage(canvas, minX, minY, cropW, cropH, 0, 0, cropW, cropH);
croppedCtx.drawImage(canvas, cropX, cropY, cropW, cropH, 0, 0, cropW, cropH);
return croppedCanvas;
}