emf-converter 4.4.12 → 4.4.13

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.
package/dist/browser.js CHANGED
@@ -15863,7 +15863,7 @@ function mirror(p, n) {
15863
15863
  }
15864
15864
  return p;
15865
15865
  }
15866
- function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical = false, edgeWidth = w, edgeHeight = h) {
15866
+ function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical = false, edgeWidth = w, edgeHeight = h, verticalRows = Math.ceil(h / w)) {
15867
15867
  const k = blurKernel(radius);
15868
15868
  const taps = (k.length - 1) / 2;
15869
15869
  const horizontalIndex = taps >= edgeWidth ? (x) => Math.max(0, Math.min(w - 1, x)) : (x) => mirror(x, w);
@@ -15893,7 +15893,7 @@ function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical
15893
15893
  }
15894
15894
  if (taps > 0 && vRow >= 0 && vRow < h) {
15895
15895
  const horizontal = out.slice();
15896
- const endRow = fullVertical ? h : Math.min(h, vRow + Math.ceil(h / w));
15896
+ const endRow = fullVertical ? h : Math.min(h, vRow + verticalRows);
15897
15897
  for (let row = vRow; row < endRow; row++) {
15898
15898
  const col = new Float64Array(w * 4);
15899
15899
  for (let j = -taps; j <= taps; j++) {
@@ -16012,13 +16012,12 @@ function copyBlock(src, width, sx, sy, w, h, dst, bw, dx, dy) {
16012
16012
  dst.set(src.subarray(from, from + w * 4), ((dy + y) * bw + dx) * 4);
16013
16013
  }
16014
16014
  }
16015
- function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1) {
16015
+ function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1, cropped) {
16016
16016
  const r = Math.ceil(radius);
16017
16017
  const bw = x1 - x0 + 2 * r;
16018
16018
  const bh = y1 - y0 + 2 * r;
16019
16019
  const buf = new Uint8ClampedArray(bw * bh * 4);
16020
- const inside = x0 - r >= 0 && y0 - r >= 0 && x1 + r <= width && y1 + r <= height;
16021
- if (inside) {
16020
+ if (cropped) {
16022
16021
  copyBlock(rgba, width, x0, y0, x1 - x0, y1 - y0, buf, bw, r, r);
16023
16022
  } else {
16024
16023
  const gx0 = Math.max(0, x0 - r);
@@ -16027,7 +16026,7 @@ function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1) {
16027
16026
  const gy1 = Math.min(height, y1 + r);
16028
16027
  copyBlock(rgba, width, gx0, gy0, gx1 - gx0, gy1 - gy0, buf, bw, gx0 - (x0 - r), gy0 - (y0 - r));
16029
16028
  }
16030
- const blurred = gdipBlur(buf, bw, bh, radius, inside ? r : 0, inside);
16029
+ const blurred = blurReduction(radius) > 1 ? effectBlur(buf, bw, bh, radius) : gdipBlur(buf, bw, bh, radius, cropped ? r : 0, cropped, false, bw, bh, Math.ceil((y1 - y0) / (x1 - x0)));
16031
16030
  const w = x1 - x0;
16032
16031
  const out = new Uint8ClampedArray(w * (y1 - y0) * 4);
16033
16032
  for (let y = 0; y < y1 - y0; y++) {
@@ -16068,7 +16067,8 @@ function applyImageEffectToRect(rgba, width, height, effect, src) {
16068
16067
  return { rgba: shown, x: x0, y: y0, width: shownWidth, height: shownHeight };
16069
16068
  };
16070
16069
  if (src && effect.kind === "blur" && effect.expandEdge) {
16071
- return result(expandedBlur(rgba, width, height, effect.radius, x0, y0, x1, y1));
16070
+ const cropped = Math.ceil(src.x + src.w) < width && Math.ceil(src.y + src.h) < height;
16071
+ return result(expandedBlur(rgba, width, height, effect.radius, x0, y0, x1, y1, cropped));
16072
16072
  }
16073
16073
  let region = rgba;
16074
16074
  if (w !== width || h !== height) {
package/dist/browser.mjs CHANGED
@@ -15861,7 +15861,7 @@ function mirror(p, n) {
15861
15861
  }
15862
15862
  return p;
15863
15863
  }
15864
- function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical = false, edgeWidth = w, edgeHeight = h) {
15864
+ function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical = false, edgeWidth = w, edgeHeight = h, verticalRows = Math.ceil(h / w)) {
15865
15865
  const k = blurKernel(radius);
15866
15866
  const taps = (k.length - 1) / 2;
15867
15867
  const horizontalIndex = taps >= edgeWidth ? (x) => Math.max(0, Math.min(w - 1, x)) : (x) => mirror(x, w);
@@ -15891,7 +15891,7 @@ function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical
15891
15891
  }
15892
15892
  if (taps > 0 && vRow >= 0 && vRow < h) {
15893
15893
  const horizontal = out.slice();
15894
- const endRow = fullVertical ? h : Math.min(h, vRow + Math.ceil(h / w));
15894
+ const endRow = fullVertical ? h : Math.min(h, vRow + verticalRows);
15895
15895
  for (let row = vRow; row < endRow; row++) {
15896
15896
  const col = new Float64Array(w * 4);
15897
15897
  for (let j = -taps; j <= taps; j++) {
@@ -16010,13 +16010,12 @@ function copyBlock(src, width, sx, sy, w, h, dst, bw, dx, dy) {
16010
16010
  dst.set(src.subarray(from, from + w * 4), ((dy + y) * bw + dx) * 4);
16011
16011
  }
16012
16012
  }
16013
- function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1) {
16013
+ function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1, cropped) {
16014
16014
  const r = Math.ceil(radius);
16015
16015
  const bw = x1 - x0 + 2 * r;
16016
16016
  const bh = y1 - y0 + 2 * r;
16017
16017
  const buf = new Uint8ClampedArray(bw * bh * 4);
16018
- const inside = x0 - r >= 0 && y0 - r >= 0 && x1 + r <= width && y1 + r <= height;
16019
- if (inside) {
16018
+ if (cropped) {
16020
16019
  copyBlock(rgba, width, x0, y0, x1 - x0, y1 - y0, buf, bw, r, r);
16021
16020
  } else {
16022
16021
  const gx0 = Math.max(0, x0 - r);
@@ -16025,7 +16024,7 @@ function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1) {
16025
16024
  const gy1 = Math.min(height, y1 + r);
16026
16025
  copyBlock(rgba, width, gx0, gy0, gx1 - gx0, gy1 - gy0, buf, bw, gx0 - (x0 - r), gy0 - (y0 - r));
16027
16026
  }
16028
- const blurred = gdipBlur(buf, bw, bh, radius, inside ? r : 0, inside);
16027
+ const blurred = blurReduction(radius) > 1 ? effectBlur(buf, bw, bh, radius) : gdipBlur(buf, bw, bh, radius, cropped ? r : 0, cropped, false, bw, bh, Math.ceil((y1 - y0) / (x1 - x0)));
16029
16028
  const w = x1 - x0;
16030
16029
  const out = new Uint8ClampedArray(w * (y1 - y0) * 4);
16031
16030
  for (let y = 0; y < y1 - y0; y++) {
@@ -16066,7 +16065,8 @@ function applyImageEffectToRect(rgba, width, height, effect, src) {
16066
16065
  return { rgba: shown, x: x0, y: y0, width: shownWidth, height: shownHeight };
16067
16066
  };
16068
16067
  if (src && effect.kind === "blur" && effect.expandEdge) {
16069
- return result(expandedBlur(rgba, width, height, effect.radius, x0, y0, x1, y1));
16068
+ const cropped = Math.ceil(src.x + src.w) < width && Math.ceil(src.y + src.h) < height;
16069
+ return result(expandedBlur(rgba, width, height, effect.radius, x0, y0, x1, y1, cropped));
16070
16070
  }
16071
16071
  let region = rgba;
16072
16072
  if (w !== width || h !== height) {
package/dist/index.js CHANGED
@@ -15864,7 +15864,7 @@ function mirror(p, n) {
15864
15864
  }
15865
15865
  return p;
15866
15866
  }
15867
- function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical = false, edgeWidth = w, edgeHeight = h) {
15867
+ function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical = false, edgeWidth = w, edgeHeight = h, verticalRows = Math.ceil(h / w)) {
15868
15868
  const k = blurKernel(radius);
15869
15869
  const taps = (k.length - 1) / 2;
15870
15870
  const horizontalIndex = taps >= edgeWidth ? (x) => Math.max(0, Math.min(w - 1, x)) : (x) => mirror(x, w);
@@ -15894,7 +15894,7 @@ function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical
15894
15894
  }
15895
15895
  if (taps > 0 && vRow >= 0 && vRow < h) {
15896
15896
  const horizontal = out.slice();
15897
- const endRow = fullVertical ? h : Math.min(h, vRow + Math.ceil(h / w));
15897
+ const endRow = fullVertical ? h : Math.min(h, vRow + verticalRows);
15898
15898
  for (let row = vRow; row < endRow; row++) {
15899
15899
  const col = new Float64Array(w * 4);
15900
15900
  for (let j = -taps; j <= taps; j++) {
@@ -16013,13 +16013,12 @@ function copyBlock(src, width, sx, sy, w, h, dst, bw, dx, dy) {
16013
16013
  dst.set(src.subarray(from, from + w * 4), ((dy + y) * bw + dx) * 4);
16014
16014
  }
16015
16015
  }
16016
- function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1) {
16016
+ function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1, cropped) {
16017
16017
  const r = Math.ceil(radius);
16018
16018
  const bw = x1 - x0 + 2 * r;
16019
16019
  const bh = y1 - y0 + 2 * r;
16020
16020
  const buf = new Uint8ClampedArray(bw * bh * 4);
16021
- const inside = x0 - r >= 0 && y0 - r >= 0 && x1 + r <= width && y1 + r <= height;
16022
- if (inside) {
16021
+ if (cropped) {
16023
16022
  copyBlock(rgba, width, x0, y0, x1 - x0, y1 - y0, buf, bw, r, r);
16024
16023
  } else {
16025
16024
  const gx0 = Math.max(0, x0 - r);
@@ -16028,7 +16027,7 @@ function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1) {
16028
16027
  const gy1 = Math.min(height, y1 + r);
16029
16028
  copyBlock(rgba, width, gx0, gy0, gx1 - gx0, gy1 - gy0, buf, bw, gx0 - (x0 - r), gy0 - (y0 - r));
16030
16029
  }
16031
- const blurred = gdipBlur(buf, bw, bh, radius, inside ? r : 0, inside);
16030
+ const blurred = blurReduction(radius) > 1 ? effectBlur(buf, bw, bh, radius) : gdipBlur(buf, bw, bh, radius, cropped ? r : 0, cropped, false, bw, bh, Math.ceil((y1 - y0) / (x1 - x0)));
16032
16031
  const w = x1 - x0;
16033
16032
  const out = new Uint8ClampedArray(w * (y1 - y0) * 4);
16034
16033
  for (let y = 0; y < y1 - y0; y++) {
@@ -16069,7 +16068,8 @@ function applyImageEffectToRect(rgba, width, height, effect, src) {
16069
16068
  return { rgba: shown, x: x0, y: y0, width: shownWidth, height: shownHeight };
16070
16069
  };
16071
16070
  if (src && effect.kind === "blur" && effect.expandEdge) {
16072
- return result(expandedBlur(rgba, width, height, effect.radius, x0, y0, x1, y1));
16071
+ const cropped = Math.ceil(src.x + src.w) < width && Math.ceil(src.y + src.h) < height;
16072
+ return result(expandedBlur(rgba, width, height, effect.radius, x0, y0, x1, y1, cropped));
16073
16073
  }
16074
16074
  let region = rgba;
16075
16075
  if (w !== width || h !== height) {
package/dist/index.mjs CHANGED
@@ -15862,7 +15862,7 @@ function mirror(p, n) {
15862
15862
  }
15863
15863
  return p;
15864
15864
  }
15865
- function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical = false, edgeWidth = w, edgeHeight = h) {
15865
+ function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical = false, edgeWidth = w, edgeHeight = h, verticalRows = Math.ceil(h / w)) {
15866
15866
  const k = blurKernel(radius);
15867
15867
  const taps = (k.length - 1) / 2;
15868
15868
  const horizontalIndex = taps >= edgeWidth ? (x) => Math.max(0, Math.min(w - 1, x)) : (x) => mirror(x, w);
@@ -15892,7 +15892,7 @@ function gdipBlur(src, w, h, radius, vRow = 0, vZeroAbove = false, fullVertical
15892
15892
  }
15893
15893
  if (taps > 0 && vRow >= 0 && vRow < h) {
15894
15894
  const horizontal = out.slice();
15895
- const endRow = fullVertical ? h : Math.min(h, vRow + Math.ceil(h / w));
15895
+ const endRow = fullVertical ? h : Math.min(h, vRow + verticalRows);
15896
15896
  for (let row = vRow; row < endRow; row++) {
15897
15897
  const col = new Float64Array(w * 4);
15898
15898
  for (let j = -taps; j <= taps; j++) {
@@ -16011,13 +16011,12 @@ function copyBlock(src, width, sx, sy, w, h, dst, bw, dx, dy) {
16011
16011
  dst.set(src.subarray(from, from + w * 4), ((dy + y) * bw + dx) * 4);
16012
16012
  }
16013
16013
  }
16014
- function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1) {
16014
+ function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1, cropped) {
16015
16015
  const r = Math.ceil(radius);
16016
16016
  const bw = x1 - x0 + 2 * r;
16017
16017
  const bh = y1 - y0 + 2 * r;
16018
16018
  const buf = new Uint8ClampedArray(bw * bh * 4);
16019
- const inside = x0 - r >= 0 && y0 - r >= 0 && x1 + r <= width && y1 + r <= height;
16020
- if (inside) {
16019
+ if (cropped) {
16021
16020
  copyBlock(rgba, width, x0, y0, x1 - x0, y1 - y0, buf, bw, r, r);
16022
16021
  } else {
16023
16022
  const gx0 = Math.max(0, x0 - r);
@@ -16026,7 +16025,7 @@ function expandedBlur(rgba, width, height, radius, x0, y0, x1, y1) {
16026
16025
  const gy1 = Math.min(height, y1 + r);
16027
16026
  copyBlock(rgba, width, gx0, gy0, gx1 - gx0, gy1 - gy0, buf, bw, gx0 - (x0 - r), gy0 - (y0 - r));
16028
16027
  }
16029
- const blurred = gdipBlur(buf, bw, bh, radius, inside ? r : 0, inside);
16028
+ const blurred = blurReduction(radius) > 1 ? effectBlur(buf, bw, bh, radius) : gdipBlur(buf, bw, bh, radius, cropped ? r : 0, cropped, false, bw, bh, Math.ceil((y1 - y0) / (x1 - x0)));
16030
16029
  const w = x1 - x0;
16031
16030
  const out = new Uint8ClampedArray(w * (y1 - y0) * 4);
16032
16031
  for (let y = 0; y < y1 - y0; y++) {
@@ -16067,7 +16066,8 @@ function applyImageEffectToRect(rgba, width, height, effect, src) {
16067
16066
  return { rgba: shown, x: x0, y: y0, width: shownWidth, height: shownHeight };
16068
16067
  };
16069
16068
  if (src && effect.kind === "blur" && effect.expandEdge) {
16070
- return result(expandedBlur(rgba, width, height, effect.radius, x0, y0, x1, y1));
16069
+ const cropped = Math.ceil(src.x + src.w) < width && Math.ceil(src.y + src.h) < height;
16070
+ return result(expandedBlur(rgba, width, height, effect.radius, x0, y0, x1, y1, cropped));
16071
16071
  }
16072
16072
  let region = rgba;
16073
16073
  if (w !== width || h !== height) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "emf-converter",
3
- "version": "4.4.12",
3
+ "version": "4.4.13",
4
4
  "description": "Convert EMF/WMF metafile binaries to PNG data URLs or SVG (markup, data URL, React/JSX)",
5
5
  "keywords": [
6
6
  "canvas",