@gehdoc/svg-to-video 0.29.4 → 0.29.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -216,6 +216,19 @@ export const analyzeSvgAnimation = (svgContent, parserOverride) => {
216
216
  }
217
217
  return undefined;
218
218
  };
219
+ /**
220
+ * Parses an SVG dimension attribute value (e.g. "100", "100px") into a pixel number.
221
+ * Returns NaN if the value is missing or uses relative/non-pixel units (e.g. "%", "em", "pt").
222
+ */
223
+ export function parsePixelDimension(val) {
224
+ if (!val)
225
+ return NaN;
226
+ const match = val.trim().match(/^([\d.eE+-]+)\s*(px)?$/i);
227
+ if (!match)
228
+ return NaN;
229
+ const num = parseFloat(match[1]);
230
+ return isNaN(num) ? NaN : num;
231
+ }
219
232
  /**
220
233
  * Parses SVG content to extract width and height from width/height attributes or viewBox.
221
234
  * Accepts an optional DOMParser override for non-browser environments.
@@ -231,8 +244,10 @@ export const parseSvgDimensions = (svgContent, parserOverride) => {
231
244
  const svg = doc.querySelector('svg');
232
245
  if (!svg)
233
246
  throw new Error('Invalid SVG content');
234
- let width = parseFloat(svg.getAttribute('width') || '');
235
- let height = parseFloat(svg.getAttribute('height') || '');
247
+ const widthAttr = svg.getAttribute('width');
248
+ const heightAttr = svg.getAttribute('height');
249
+ let width = parsePixelDimension(widthAttr);
250
+ let height = parsePixelDimension(heightAttr);
236
251
  const viewBox = svg.getAttribute('viewBox');
237
252
  let isDimensionsDetected = !(isNaN(width) || isNaN(height));
238
253
  if (!isDimensionsDetected && viewBox) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gehdoc/svg-to-video",
3
3
  "mcpName": "io.github.GehDoc/svg-to-video",
4
- "version": "0.29.4",
4
+ "version": "0.29.5",
5
5
  "type": "module",
6
6
  "description": "Professional animated SVG to Video (MP4/WebM/MKV/MOV) and Animated Image (aPNG/GIF) converter featuring frame-accurate rendering, CLI automation, Model Context Protocol (MCP) server integration, and a serverless Web Studio.",
7
7
  "imports": {