From 81d3eca3c98caa945ada9b1f4c5e77de31a5a2c6 Mon Sep 17 00:00:00 2001 From: Gregory JSWhisperer Date: Mon, 11 Aug 2025 21:28:18 +0100 Subject: [PATCH 1/2] feature: container width an idea for resizing the container El similar to html2canvas rather than rendered image --- src/core/capture.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/core/capture.js b/src/core/capture.js index b355ef1..f6e3306 100644 --- a/src/core/capture.js +++ b/src/core/capture.js @@ -37,6 +37,9 @@ export async function captureDOM(element, options = {}) { ({ clone, classCSS } = await prepareClone(element, compress, embedFonts, options)); + options.width && clone.setAttribute("width", options.width + 'px'); + options.height && clone.setAttribute("height", options.height + 'px'); + await new Promise((resolve) => { idle(async () => { await inlineImages(clone, options); From e5b3d755660d058af4970341af178ecf940ce139 Mon Sep 17 00:00:00 2001 From: Gregory JSWhisperer Date: Mon, 11 Aug 2025 21:28:53 +0100 Subject: [PATCH 2/2] feature: container width WIP an idea for resizing the container El similar to html2canvas rather than rendered image --- src/core/capture.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/core/capture.js b/src/core/capture.js index f6e3306..7f2af87 100644 --- a/src/core/capture.js +++ b/src/core/capture.js @@ -3,13 +3,13 @@ * @module capture */ -import { prepareClone } from './prepare.js'; -import { inlineImages } from '../modules/images.js'; +import { cache } from '../core/cache.js'; import { inlineBackgroundImages } from '../modules/background.js'; -import { idle, isSafari } from '../utils/helpers.js'; -import { collectUsedTagNames, generateDedupedBaseCSS } from '../utils/cssTools.js'; import { embedCustomFonts } from '../modules/fonts.js'; -import { cache } from '../core/cache.js' +import { inlineImages } from '../modules/images.js'; +import { collectUsedTagNames, generateDedupedBaseCSS } from '../utils/cssTools.js'; +import { idle } from '../utils/helpers.js'; +import { prepareClone } from './prepare.js'; /** * Captures an HTML element as an SVG data URL, inlining styles, images, backgrounds, and optionally fonts. @@ -21,7 +21,7 @@ import { cache } from '../core/cache.js' * @param {boolean} [options.fast=true] - Whether to skip idle delay for faster results * @param {number} [options.scale=1] - Output scale multiplier * @param {string[]} [options.exclude] - CSS selectors for elements to exclude - * @param {Function} [options.filter] - Custom filter function + * @param {Function} [options.filter] - Custom filter function * @returns {Promise} Promise that resolves to an SVG data URL */