@blocklet/images 1.16.37-beta-20250102-115729-ae7f327e → 1.16.37-beta-20250106-134442-ea92021c

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/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2018-2020 ArcBlock
1
+ Copyright 2018-2025 ArcBlock
2
2
 
3
3
  Licensed under the Apache License, Version 2.0 (the "License");
4
4
  you may not use this file except in compliance with the License.
package/lib/blurhash.js CHANGED
@@ -9,14 +9,24 @@ const jimp_1 = require("jimp");
9
9
  const utils_1 = require("@jimp/utils");
10
10
  const blurhash_1 = require("blurhash");
11
11
  const image_type_1 = __importDefault(require("image-type"));
12
+ const is_svg_1 = __importDefault(require("is-svg"));
13
+ const resvg_js_1 = require("@resvg/resvg-js");
12
14
  async function getBlurhash(filePath) {
13
15
  if (!fs_1.default.existsSync(filePath)) {
14
16
  throw new Error(`File not found: ${filePath}`);
15
17
  }
16
- const buffer = fs_1.default.readFileSync(filePath);
18
+ let buffer = fs_1.default.readFileSync(filePath);
17
19
  const type = (0, image_type_1.default)(buffer);
18
20
  if (!type) {
19
- throw new Error(`File is not a valid image: ${filePath}`);
21
+ // svg 转位图
22
+ 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}`);
29
+ }
20
30
  }
21
31
  // Read image using Jimp
22
32
  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.37-beta-20250102-115729-ae7f327e",
3
+ "version": "1.16.37-beta-20250106-134442-ea92021c",
4
4
  "main": "lib/index.js",
5
5
  "types": "./lib/index.d.ts",
6
6
  "license": "MIT",
@@ -38,6 +38,7 @@
38
38
  },
39
39
  "dependencies": {
40
40
  "@jimp/utils": "^1.6.0",
41
+ "@resvg/resvg-js": "^2.6.2",
41
42
  "blurhash": "^2.0.5",
42
43
  "image-size": "^1.0.2",
43
44
  "image-type": "^4.1.0",
@@ -54,5 +55,5 @@
54
55
  "ts-node": "^10.9.1",
55
56
  "typescript": "^5.6.3"
56
57
  },
57
- "gitHead": "3f2d744095b2056010fdd1635841857a65f12232"
58
+ "gitHead": "3ca08cceb016a318c7c00ec1f1bef4db19a3c723"
58
59
  }