node-automator 1.4.13 → 1.4.14

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,18 +1,26 @@
1
- const { get_fst_file, get_full_path } = require('../utils/file_tool');
2
- const { log, getPrint } = require('../utils/log_tool');
1
+ const path = require('path');
2
+ const { get_fst_file, get_full_path, move } = require('../utils/file_tool');
3
3
  const { BaseCommand } = require("./base");
4
- const Jimp = require("jimp");
5
4
 
6
5
  class CompressCommand extends BaseCommand {
7
6
  async execute() {
7
+ const sharp = require("sharp");
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
- const options = data.options || {};
12
- let image = await Jimp.read(src);
13
- image.scale(options.scale || 1);
14
- image.quality(options.quality || 80);
15
- await image.writeAsync(dst);
11
+ const tmp = path.join(this.shareData.AUTOMATOR_SCRATCH, path.basename(src));
12
+ let format = data.format;
13
+ if (!format) {
14
+ format = dst.split(".").pop();
15
+ }
16
+ format = format.toLowerCase();
17
+ if (format === "jpg") {
18
+ format = "jpeg";
19
+ }
20
+ const options = data.options;
21
+ await sharp(src)[format](options)
22
+ .toFile(tmp);
23
+ await move(tmp, path.dirname(dst));
16
24
  }
17
25
  }
18
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-automator",
3
- "version": "1.4.13",
3
+ "version": "1.4.14",
4
4
  "description": "Execute automation with yaml configuration(compatible with json)",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -52,6 +52,7 @@
52
52
  "persist-path": "^1.0.2",
53
53
  "request": "^2.88.2",
54
54
  "request-progress": "^3.0.0",
55
+ "sharp": "^0.34.3",
55
56
  "spreadsheet-column": "^1.1.1",
56
57
  "strip-json-comments": "^3.1.1",
57
58
  "temp": "^0.9.4",