node-automator 1.4.4 → 1.4.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.
@@ -1,24 +1,17 @@
1
1
  const { get_fst_file, get_full_path } = require('../utils/file_tool');
2
2
  const { log, getPrint } = require('../utils/log_tool');
3
3
  const { BaseCommand } = require("./base");
4
- const sharp = require("sharp");
4
+ const Jimp = require("jimp");
5
5
 
6
6
  class CompressCommand extends BaseCommand {
7
7
  async execute() {
8
8
  const data = this.selfData;
9
9
  const src = get_fst_file(data.src);
10
10
  const dst = get_full_path(data.dst, "FILE");
11
- let format = data.format;
12
- if (!format) {
13
- format = dst.split(".").pop();
14
- }
15
- format = format.toLowerCase();
16
- if (format === "jpg") {
17
- format = "jpeg";
18
- }
19
- const options = data.options;
20
- await sharp(src)[format](options)
21
- .toFile(dst);
11
+ const options = data.options || {};
12
+ let image = await Jimp.read(src);
13
+ image.quality(options.quality || 80);
14
+ await image.writeAsync(dst);
22
15
  }
23
16
  }
24
17
 
@@ -1,19 +1,16 @@
1
1
  const { get_fst_file, get_full_path } = require('../utils/file_tool');
2
2
  const { BaseCommand } = require("./base");
3
- const sharp = require("sharp");
3
+ const Jimp = require("jimp");
4
4
 
5
5
  class ImageCropCommand extends BaseCommand {
6
6
  async execute() {
7
7
  const data = this.selfData;
8
8
  const src = get_fst_file(data.src);
9
+ const image = await Jimp.read(src);
9
10
  const {x, y, w, h} = data.region;
10
- const dst = get_full_path(data.dst, "FILE");
11
- await sharp(src).extract({
12
- left: x,
13
- top: y,
14
- width: w,
15
- height: h,
16
- }).toFile(dst);
11
+ const croped = image.crop(x, y, w, h);
12
+ const dst = get_full_path(data.dst);
13
+ await croped.writeAsync(dst);
17
14
  }
18
15
  }
19
16
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-automator",
3
- "version": "1.4.4",
3
+ "version": "1.4.5",
4
4
  "description": "Execute automation with yaml configuration(compatible with json)",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -34,6 +34,7 @@
34
34
  "html-to-text": "^8.2.0",
35
35
  "iconv-lite": "^0.6.2",
36
36
  "image-size": "^1.0.0",
37
+ "jimp": "^0.22.12",
37
38
  "json-stable-stringify": "^1.0.1",
38
39
  "jwt-js": "^0.5.0",
39
40
  "keypress": "^0.2.1",
@@ -49,7 +50,6 @@
49
50
  "persist-path": "^1.0.2",
50
51
  "request": "^2.88.2",
51
52
  "request-progress": "^3.0.0",
52
- "sharp": "^0.33.5",
53
53
  "spreadsheet-column": "^1.1.1",
54
54
  "strip-json-comments": "^3.1.1",
55
55
  "temp": "^0.9.4",