@blocklet/images 1.16.41-beta-20250317-081605-78d4ac9f → 1.16.41-beta-20250318-123609-b48bb2d7

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.
Files changed (2) hide show
  1. package/lib/blurhash.js +4 -8
  2. package/package.json +2 -3
package/lib/blurhash.js CHANGED
@@ -10,23 +10,19 @@ const utils_1 = require("@jimp/utils");
10
10
  const blurhash_1 = require("blurhash");
11
11
  const image_type_1 = __importDefault(require("image-type"));
12
12
  const is_svg_1 = __importDefault(require("is-svg"));
13
- const resvg_js_1 = require("@resvg/resvg-js");
14
13
  async function getBlurhash(filePath) {
15
14
  if (!fs_1.default.existsSync(filePath)) {
16
15
  throw new Error(`File not found: ${filePath}`);
17
16
  }
18
- let buffer = fs_1.default.readFileSync(filePath);
17
+ const buffer = fs_1.default.readFileSync(filePath);
19
18
  const type = (0, image_type_1.default)(buffer);
20
19
  if (!type) {
21
20
  // svg 转位图
22
21
  if ((0, is_svg_1.default)(buffer)) {
23
- const svg = buffer.toString('utf-8');
24
- const resvg = new resvg_js_1.Resvg(svg);
25
- buffer = resvg.render().asPng();
26
- }
27
- else {
28
- throw new Error(`File is not a valid image: ${filePath}`);
22
+ // return empty blurhash
23
+ return '';
29
24
  }
25
+ throw new Error(`File is not a valid image: ${filePath}`);
30
26
  }
31
27
  // Read image using Jimp
32
28
  const image = await jimp_1.Jimp.read(buffer);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/images",
3
- "version": "1.16.41-beta-20250317-081605-78d4ac9f",
3
+ "version": "1.16.41-beta-20250318-123609-b48bb2d7",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "MIT",
@@ -38,7 +38,6 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@jimp/utils": "^1.6.0",
41
- "@resvg/resvg-js": "^2.6.2",
42
41
  "blurhash": "^2.0.5",
43
42
  "image-size": "^1.0.2",
44
43
  "image-type": "^4.1.0",
@@ -55,5 +54,5 @@
55
54
  "ts-node": "^10.9.1",
56
55
  "typescript": "^5.6.3"
57
56
  },
58
- "gitHead": "f1bf0dcd30bd27d7d42ac76f62ea90da57530479"
57
+ "gitHead": "bb26547e22d71d208582b6254c355598a42f363b"
59
58
  }