Skip to content

Commit a4ed333

Browse files
feat: reduce image export scaling to a clean 2x factor to avoid excessively large file sizes
1 parent e3ff7e5 commit a4ed333

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

script.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10249,7 +10249,7 @@ document.addEventListener("DOMContentLoaded", async function () {
1024910249
function svgToCanvas(svgEl) {
1025010250
return new Promise((resolve, reject) => {
1025110251
const bbox = svgEl.getBoundingClientRect();
10252-
const scale = Math.max(window.devicePixelRatio || 1, 3);
10252+
const scale = 2; // 2x scale for high quality without excessive file size
1025310253
const width = Math.max(Math.round(bbox.width), 1);
1025410254
const height = Math.max(Math.round(bbox.height), 1);
1025510255

@@ -10843,7 +10843,7 @@ document.addEventListener("DOMContentLoaded", async function () {
1084310843
return new Promise((resolve, reject) => {
1084410844
try {
1084510845
const canvas = document.createElement('canvas');
10846-
const scale = 3; // 3x scale for high-definition (crisp text)
10846+
const scale = 2; // 2x scale for high quality without being excessively large
1084710847

1084810848
let width = imgEl.naturalWidth || imgEl.width || 800;
1084910849
let height = imgEl.naturalHeight || imgEl.height || 600;
@@ -10853,13 +10853,6 @@ document.addEventListener("DOMContentLoaded", async function () {
1085310853
height = originalDim.height;
1085410854
}
1085510855

10856-
// Enforce a minimum base width of 1600px to guarantee crisp detail on large D2 diagrams
10857-
if (width < 1600) {
10858-
const aspect = height / width;
10859-
width = 1600;
10860-
height = width * aspect;
10861-
}
10862-
1086310856
canvas.width = width * scale;
1086410857
canvas.height = height * scale;
1086510858

0 commit comments

Comments
 (0)