cyberchef 10.22.1 → 10.24.0

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 (118) hide show
  1. package/CHANGELOG.md +182 -0
  2. package/CONTRIBUTING.md +40 -0
  3. package/Dockerfile +2 -0
  4. package/Gruntfile.js +2 -28
  5. package/README.md +1 -1
  6. package/babel.config.js +0 -6
  7. package/package.json +64 -63
  8. package/src/core/Chef.mjs +8 -1
  9. package/src/core/Ingredient.mjs +5 -2
  10. package/src/core/Operation.mjs +6 -1
  11. package/src/core/Recipe.mjs +10 -5
  12. package/src/core/config/Categories.json +20 -4
  13. package/src/core/config/OperationConfig.json +550 -26
  14. package/src/core/config/modules/Ciphers.mjs +6 -0
  15. package/src/core/config/modules/Crypto.mjs +6 -0
  16. package/src/core/config/modules/Default.mjs +8 -0
  17. package/src/core/config/modules/Shellcode.mjs +2 -0
  18. package/src/core/config/scripts/fixCryptoApiImports.mjs +54 -0
  19. package/src/core/config/scripts/fixSnackBarMarkup.mjs +28 -0
  20. package/src/core/lib/AudioBytes.mjs +103 -0
  21. package/src/core/lib/AudioMetaSchema.mjs +82 -0
  22. package/src/core/lib/AudioParsers.mjs +630 -0
  23. package/src/core/lib/BigIntUtils.mjs +73 -0
  24. package/src/core/lib/Extract.mjs +5 -0
  25. package/src/core/lib/Modhex.mjs +2 -0
  26. package/src/core/lib/ParityBit.mjs +50 -0
  27. package/src/core/lib/QRCode.mjs +30 -10
  28. package/src/core/lib/RC6.mjs +625 -0
  29. package/src/core/operations/A1Z26CipherDecode.mjs +1 -1
  30. package/src/core/operations/AddTextToImage.mjs +116 -64
  31. package/src/core/operations/AnalyseUUID.mjs +109 -6
  32. package/src/core/operations/BlurImage.mjs +10 -12
  33. package/src/core/operations/ContainImage.mjs +50 -40
  34. package/src/core/operations/ConvertImageFormat.mjs +33 -39
  35. package/src/core/operations/CoverImage.mjs +39 -37
  36. package/src/core/operations/CropImage.mjs +35 -21
  37. package/src/core/operations/DisassembleARM.mjs +193 -0
  38. package/src/core/operations/DitherImage.mjs +8 -8
  39. package/src/core/operations/EscapeUnicodeCharacters.mjs +0 -17
  40. package/src/core/operations/ExtractAudioMetadata.mjs +175 -0
  41. package/src/core/operations/ExtractEmailAddresses.mjs +2 -3
  42. package/src/core/operations/ExtractLSB.mjs +17 -11
  43. package/src/core/operations/ExtractRGBA.mjs +12 -10
  44. package/src/core/operations/FlaskSessionDecode.mjs +80 -0
  45. package/src/core/operations/FlaskSessionSign.mjs +89 -0
  46. package/src/core/operations/FlaskSessionVerify.mjs +136 -0
  47. package/src/core/operations/FlipImage.mjs +14 -10
  48. package/src/core/operations/GenerateImage.mjs +39 -32
  49. package/src/core/operations/ImageBrightnessContrast.mjs +10 -10
  50. package/src/core/operations/ImageFilter.mjs +14 -13
  51. package/src/core/operations/ImageHueSaturationLightness.mjs +22 -20
  52. package/src/core/operations/ImageOpacity.mjs +6 -8
  53. package/src/core/operations/InvertImage.mjs +4 -6
  54. package/src/core/operations/Jq.mjs +12 -4
  55. package/src/core/operations/NormaliseImage.mjs +5 -7
  56. package/src/core/operations/OffsetChecker.mjs +1 -1
  57. package/src/core/operations/ParityBit.mjs +128 -0
  58. package/src/core/operations/ParseEthernetFrame.mjs +112 -0
  59. package/src/core/operations/ParseIPv4Header.mjs +23 -6
  60. package/src/core/operations/ParseQRCode.mjs +13 -13
  61. package/src/core/operations/PseudoRandomIntegerGenerator.mjs +164 -0
  62. package/src/core/operations/RC6Decrypt.mjs +119 -0
  63. package/src/core/operations/RC6Encrypt.mjs +119 -0
  64. package/src/core/operations/RandomizeColourPalette.mjs +11 -11
  65. package/src/core/operations/RegularExpression.mjs +2 -1
  66. package/src/core/operations/RenderMarkdown.mjs +35 -4
  67. package/src/core/operations/ResizeImage.mjs +30 -23
  68. package/src/core/operations/RotateImage.mjs +8 -9
  69. package/src/core/operations/SQLBeautify.mjs +21 -3
  70. package/src/core/operations/SharpenImage.mjs +94 -62
  71. package/src/core/operations/SplitColourChannels.mjs +47 -21
  72. package/src/core/operations/TextIntegerConverter.mjs +123 -0
  73. package/src/core/operations/UnescapeUnicodeCharacters.mjs +17 -0
  74. package/src/core/operations/ViewBitPlane.mjs +16 -20
  75. package/src/core/operations/index.mjs +22 -0
  76. package/src/node/index.mjs +55 -0
  77. package/src/web/HTMLIngredient.mjs +24 -43
  78. package/src/web/HTMLOperation.mjs +8 -2
  79. package/src/web/Manager.mjs +1 -0
  80. package/src/web/html/index.html +6 -6
  81. package/src/web/static/fonts/bmfonts/Roboto72White.fnt +491 -485
  82. package/src/web/static/fonts/bmfonts/RobotoBlack72White.fnt +494 -488
  83. package/src/web/static/fonts/bmfonts/RobotoMono72White.fnt +110 -103
  84. package/src/web/static/fonts/bmfonts/RobotoSlab72White.fnt +498 -492
  85. package/src/web/stylesheets/layout/_banner.css +30 -0
  86. package/src/web/stylesheets/layout/_modals.css +5 -0
  87. package/src/web/stylesheets/utils/_overrides.css +7 -0
  88. package/src/web/waiters/ControlsWaiter.mjs +82 -0
  89. package/src/web/waiters/InputWaiter.mjs +12 -6
  90. package/src/web/waiters/OperationsWaiter.mjs +30 -13
  91. package/src/web/waiters/RecipeWaiter.mjs +2 -2
  92. package/tests/browser/02_ops.js +23 -3
  93. package/tests/node/index.mjs +1 -0
  94. package/tests/node/tests/lib/BigIntUtils.mjs +150 -0
  95. package/tests/node/tests/operations.mjs +11 -10
  96. package/tests/operations/index.mjs +13 -0
  97. package/tests/operations/tests/A1Z26CipherDecode.mjs +33 -0
  98. package/tests/operations/tests/AnalyseUUID.mjs +66 -0
  99. package/tests/operations/tests/DisassembleARM.mjs +377 -0
  100. package/tests/operations/tests/ExtractAudioMetadata.mjs +287 -0
  101. package/tests/operations/tests/ExtractEmailAddresses.mjs +38 -12
  102. package/tests/operations/tests/Fernet.mjs +18 -3
  103. package/tests/operations/tests/FlaskSession.mjs +246 -0
  104. package/tests/operations/tests/GenerateQRCode.mjs +67 -0
  105. package/tests/operations/tests/JWTSign.mjs +83 -8
  106. package/tests/operations/tests/Jq.mjs +32 -0
  107. package/tests/operations/tests/Modhex.mjs +20 -0
  108. package/tests/operations/tests/ParityBit.mjs +147 -0
  109. package/tests/operations/tests/ParseEthernetFrame.mjs +45 -0
  110. package/tests/operations/tests/RC6.mjs +487 -0
  111. package/tests/operations/tests/RegularExpression.mjs +75 -0
  112. package/tests/operations/tests/RenderMarkdown.mjs +110 -0
  113. package/tests/operations/tests/SQLBeautify.mjs +54 -0
  114. package/tests/operations/tests/TextIntegerConverter.mjs +199 -0
  115. package/tests/samples/Audio.mjs +73 -0
  116. package/tests/samples/Images.mjs +0 -12
  117. package/webpack.config.js +10 -7
  118. package/src/core/lib/ImageManipulation.mjs +0 -251
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @author ThePlayer372-FR []
3
+ * @license Apache-2.0
4
+ */
5
+
6
+ import Operation from "../Operation.mjs";
7
+ import CryptoApi from "crypto-api/src/crypto-api.mjs";
8
+ import Utils from "../Utils.mjs";
9
+ import { toBase64 } from "../lib/Base64.mjs";
10
+ import OperationError from "../errors/OperationError.mjs";
11
+
12
+ /**
13
+ * Flask Session Sign operation
14
+ */
15
+ class FlaskSessionSign extends Operation {
16
+ /**
17
+ * FlaskSessionSign constructor
18
+ */
19
+ constructor() {
20
+ super();
21
+
22
+ this.name = "Flask Session Sign";
23
+ this.module = "Crypto";
24
+ this.description = "Signs a JSON payload to produce a Flask session cookie (itsdangerous HMAC).";
25
+ this.inputType = "JSON";
26
+ this.outputType = "string";
27
+ this.args = [
28
+ {
29
+ name: "Key",
30
+ type: "toggleString",
31
+ value: "",
32
+ toggleValues: ["Hex", "Decimal", "Binary", "Base64", "UTF8", "Latin1"]
33
+ },
34
+ {
35
+ name: "Salt",
36
+ type: "toggleString",
37
+ value: "cookie-session",
38
+ toggleValues: ["UTF8", "Hex", "Decimal", "Binary", "Base64", "Latin1"]
39
+ },
40
+ {
41
+ name: "Algorithm",
42
+ type: "option",
43
+ value: ["sha1", "sha256"],
44
+ }
45
+ ];
46
+ }
47
+
48
+ /**
49
+ * @param {string} input
50
+ * @param {Object[]} args
51
+ * @returns {string}
52
+ */
53
+ run(input, args) {
54
+ if (!args[0].string) {
55
+ throw new OperationError("Secret key required");
56
+ }
57
+ const key = Utils.convertToByteString(args[0].string, args[0].option);
58
+ const salt = Utils.convertToByteString(args[1].string || "cookie-session", args[1].option);
59
+ const algorithm = args[2] || "sha1";
60
+
61
+ const payloadB64 = toBase64(Utils.strToByteArray(JSON.stringify(input)));
62
+ const payload = payloadB64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
63
+
64
+ const derivedKey = CryptoApi.getHmac(key, CryptoApi.getHasher(algorithm));
65
+ derivedKey.update(salt);
66
+
67
+ const currentTimeStamp = Math.ceil(Date.now() / 1000);
68
+ const buffer = new ArrayBuffer(4);
69
+ const view = new DataView(buffer);
70
+ view.setInt32(0, currentTimeStamp, false);
71
+ const bytes = new Uint8Array(buffer);
72
+ let binary = "";
73
+ bytes.forEach(b => binary += String.fromCharCode(b));
74
+ const timeB64 = toBase64(Utils.strToByteArray(binary));
75
+ const time = timeB64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
76
+
77
+ const data = Utils.convertToByteString(payload + "." + time, "utf8");
78
+ const sign = CryptoApi.getHmac(derivedKey.finalize(), CryptoApi.getHasher(algorithm));
79
+ sign.update(data);
80
+
81
+ const signB64 = toBase64(sign.finalize());
82
+ const sign64 = signB64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
83
+
84
+ return payload + "." + time + "." + sign64;
85
+ }
86
+ }
87
+
88
+
89
+ export default FlaskSessionSign;
@@ -0,0 +1,136 @@
1
+ /**
2
+ * @author ThePlayer372-FR []
3
+ * @license Apache-2.0
4
+ */
5
+
6
+ import Operation from "../Operation.mjs";
7
+ import OperationError from "../errors/OperationError.mjs";
8
+ import CryptoApi from "crypto-api/src/crypto-api.mjs";
9
+ import Utils from "../Utils.mjs";
10
+ import { toBase64, fromBase64 } from "../lib/Base64.mjs";
11
+
12
+ /**
13
+ * Flask Session Verify operation
14
+ */
15
+ class FlaskSessionVerify extends Operation {
16
+ /**
17
+ * FlaskSessionVerify constructor
18
+ */
19
+ constructor() {
20
+ super();
21
+
22
+ this.name = "Flask Session Verify";
23
+ this.module = "Crypto";
24
+ this.description = "Verifies the HMAC signature of a Flask session cookie (itsdangerous) generated.";
25
+ this.inputType = "string";
26
+ this.outputType = "JSON";
27
+ this.args = [
28
+ {
29
+ name: "Key",
30
+ type: "toggleString",
31
+ value: "",
32
+ toggleValues: ["Hex", "Decimal", "Binary", "Base64", "UTF8", "Latin1"]
33
+ },
34
+ {
35
+ name: "Salt",
36
+ type: "toggleString",
37
+ value: "cookie-session",
38
+ toggleValues: ["UTF8", "Hex", "Decimal", "Binary", "Base64", "Latin1"]
39
+ },
40
+ {
41
+ name: "Algorithm",
42
+ type: "option",
43
+ value: ["sha1", "sha256"],
44
+ },
45
+ {
46
+ name: "View TimeStamp",
47
+ type: "boolean",
48
+ value: true
49
+ }
50
+ ];
51
+ }
52
+
53
+ /**
54
+ * @param {string} input
55
+ * @param {Object[]} args
56
+ * @returns {string}
57
+ */
58
+ run(input, args) {
59
+
60
+ if (!args[0].string) {
61
+ throw new OperationError("Secret key required");
62
+ }
63
+
64
+ const key = Utils.convertToByteString(args[0].string, args[0].option);
65
+ const salt = Utils.convertToByteString(args[1].string || "cookie-session", args[1].option);
66
+ const algorithm = args[2] || "sha1";
67
+
68
+ input = input.trim();
69
+
70
+ const parts = input.split(".");
71
+
72
+ if (parts.length !== 3) {
73
+ throw new OperationError("Invalid Flask token format. Expected payload.timestamp.signature");
74
+ }
75
+
76
+ const data = Utils.convertToByteString(parts[0] + "." + parts[1], "utf8");
77
+
78
+
79
+ const derivedKey = CryptoApi.getHmac(key, CryptoApi.getHasher(algorithm));
80
+ derivedKey.update(salt);
81
+
82
+ const sign = CryptoApi.getHmac(derivedKey.finalize(), CryptoApi.getHasher(algorithm));
83
+ sign.update(data);
84
+
85
+ const payloadB64 = parts[0];
86
+ const base64 = payloadB64.replace(/-/g, "+").replace(/_/g, "/");
87
+ const padded = base64.padEnd(Math.ceil(base64.length / 4) * 4, "=");
88
+
89
+ const time = parts[1];
90
+
91
+ const timeB64 = time.replace(/-/g, "+").replace(/_/g, "/");
92
+ const binary = fromBase64(timeB64);
93
+ const bytes = new Uint8Array(4);
94
+ for (let i = 0; i < 4; i++) {
95
+ bytes[i] = binary.charCodeAt(i);
96
+ }
97
+ const view = new DataView(bytes.buffer);
98
+ const timestamp = view.getInt32(0, false);
99
+
100
+ let payloadJson;
101
+ try {
102
+ payloadJson = fromBase64(padded);
103
+ } catch (e) {
104
+ throw new OperationError("Invalid Base64 payload");
105
+ }
106
+
107
+ const signB64 = toBase64(sign.finalize());
108
+ const sign64 = signB64.replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
109
+
110
+ if (sign64 !== parts[2]) {
111
+ throw new OperationError("Invalid signature!");
112
+ }
113
+
114
+ try {
115
+ const decoded = JSON.parse(payloadJson);
116
+ if (!args[3]) {
117
+ return {
118
+ valid: true,
119
+ payload: decoded,
120
+ };
121
+ } else {
122
+ return {
123
+ valid: true,
124
+ payload: decoded,
125
+ timestamp: timestamp
126
+ };
127
+ }
128
+ } catch (e) {
129
+ throw new OperationError("Unable to decode JSON payload: " + e.message);
130
+ }
131
+
132
+ }
133
+ }
134
+
135
+
136
+ export default FlaskSessionVerify;
@@ -9,13 +9,12 @@ import OperationError from "../errors/OperationError.mjs";
9
9
  import { isImage } from "../lib/FileType.mjs";
10
10
  import { toBase64 } from "../lib/Base64.mjs";
11
11
  import { isWorkerEnvironment } from "../Utils.mjs";
12
- import Jimp from "jimp/es/index.js";
12
+ import { Jimp, JimpMime } from "jimp";
13
13
 
14
14
  /**
15
15
  * Flip Image operation
16
16
  */
17
17
  class FlipImage extends Operation {
18
-
19
18
  /**
20
19
  * FlipImage constructor
21
20
  */
@@ -33,8 +32,8 @@ class FlipImage extends Operation {
33
32
  {
34
33
  name: "Axis",
35
34
  type: "option",
36
- value: ["Horizontal", "Vertical"]
37
- }
35
+ value: ["Horizontal", "Vertical"],
36
+ },
38
37
  ];
39
38
  }
40
39
 
@@ -60,18 +59,24 @@ class FlipImage extends Operation {
60
59
  self.sendStatusMessage("Flipping image...");
61
60
  switch (flipAxis) {
62
61
  case "Horizontal":
63
- image.flip(true, false);
62
+ image.flip({
63
+ horizontal: true,
64
+ vertical: false,
65
+ });
64
66
  break;
65
67
  case "Vertical":
66
- image.flip(false, true);
68
+ image.flip({
69
+ horizontal: false,
70
+ vertical: true,
71
+ });
67
72
  break;
68
73
  }
69
74
 
70
75
  let imageBuffer;
71
- if (image.getMIME() === "image/gif") {
72
- imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
76
+ if (image.mime === "image/gif") {
77
+ imageBuffer = await image.getBuffer(JimpMime.png);
73
78
  } else {
74
- imageBuffer = await image.getBufferAsync(Jimp.AUTO);
79
+ imageBuffer = await image.getBuffer(image.mime);
75
80
  }
76
81
  return imageBuffer.buffer;
77
82
  } catch (err) {
@@ -95,7 +100,6 @@ class FlipImage extends Operation {
95
100
 
96
101
  return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
97
102
  }
98
-
99
103
  }
100
104
 
101
105
  export default FlipImage;
@@ -7,16 +7,15 @@
7
7
  import Operation from "../Operation.mjs";
8
8
  import OperationError from "../errors/OperationError.mjs";
9
9
  import Utils from "../Utils.mjs";
10
- import {isImage} from "../lib/FileType.mjs";
11
- import {toBase64} from "../lib/Base64.mjs";
12
- import {isWorkerEnvironment} from "../Utils.mjs";
13
- import Jimp from "jimp/es/index.js";
10
+ import { isImage } from "../lib/FileType.mjs";
11
+ import { toBase64 } from "../lib/Base64.mjs";
12
+ import { isWorkerEnvironment } from "../Utils.mjs";
13
+ import { Jimp, JimpMime, ResizeStrategy, rgbaToInt } from "jimp";
14
14
 
15
15
  /**
16
16
  * Generate Image operation
17
17
  */
18
18
  class GenerateImage extends Operation {
19
-
20
19
  /**
21
20
  * GenerateImage constructor
22
21
  */
@@ -25,27 +24,28 @@ class GenerateImage extends Operation {
25
24
 
26
25
  this.name = "Generate Image";
27
26
  this.module = "Image";
28
- this.description = "Generates an image using the input as pixel values.";
27
+ this.description =
28
+ "Generates an image using the input as pixel values.";
29
29
  this.infoURL = "";
30
30
  this.inputType = "ArrayBuffer";
31
31
  this.outputType = "ArrayBuffer";
32
32
  this.presentType = "html";
33
33
  this.args = [
34
34
  {
35
- "name": "Mode",
36
- "type": "option",
37
- "value": ["Greyscale", "RG", "RGB", "RGBA", "Bits"]
35
+ name: "Mode",
36
+ type: "option",
37
+ value: ["Greyscale", "RG", "RGB", "RGBA", "Bits"],
38
38
  },
39
39
  {
40
- "name": "Pixel Scale Factor",
41
- "type": "number",
42
- "value": 8,
40
+ name: "Pixel Scale Factor",
41
+ type: "number",
42
+ value: 8,
43
43
  },
44
44
  {
45
- "name": "Pixels per row",
46
- "type": "number",
47
- "value": 64,
48
- }
45
+ name: "Pixels per row",
46
+ type: "number",
47
+ value: 64,
48
+ },
49
49
  ];
50
50
  }
51
51
 
@@ -67,21 +67,23 @@ class GenerateImage extends Operation {
67
67
  }
68
68
 
69
69
  const bytePerPixelMap = {
70
- "Greyscale": 1,
71
- "RG": 2,
72
- "RGB": 3,
73
- "RGBA": 4,
74
- "Bits": 1/8,
70
+ Greyscale: 1,
71
+ RG: 2,
72
+ RGB: 3,
73
+ RGBA: 4,
74
+ Bits: 1 / 8,
75
75
  };
76
76
 
77
77
  const bytesPerPixel = bytePerPixelMap[mode];
78
78
 
79
- if (bytesPerPixel > 0 && input.length % bytesPerPixel !== 0) {
80
- throw new OperationError(`Number of bytes is not a divisor of ${bytesPerPixel}`);
79
+ if (bytesPerPixel > 0 && input.length % bytesPerPixel !== 0) {
80
+ throw new OperationError(
81
+ `Number of bytes is not a divisor of ${bytesPerPixel}`,
82
+ );
81
83
  }
82
84
 
83
85
  const height = Math.ceil(input.length / bytesPerPixel / width);
84
- const image = await new Jimp(width, height, (err, image) => {});
86
+ const image = new Jimp({ width, height });
85
87
 
86
88
  if (isWorkerEnvironment())
87
89
  self.sendStatusMessage("Generating image from data...");
@@ -94,8 +96,8 @@ class GenerateImage extends Operation {
94
96
  const x = index % width;
95
97
  const y = Math.floor(index / width);
96
98
 
97
- const value = curByte[k] === "0" ? 0xFF : 0x00;
98
- const pixel = Jimp.rgbaToInt(value, value, value, 0xFF);
99
+ const value = curByte[k] === "0" ? 0xff : 0x00;
100
+ const pixel = rgbaToInt(value, value, value, 0xff);
99
101
  image.setPixelColor(pixel, x, y);
100
102
  }
101
103
  }
@@ -109,7 +111,7 @@ class GenerateImage extends Operation {
109
111
  let red = 0x00;
110
112
  let green = 0x00;
111
113
  let blue = 0x00;
112
- let alpha = 0xFF;
114
+ let alpha = 0xff;
113
115
 
114
116
  switch (mode) {
115
117
  case "Greyscale":
@@ -139,10 +141,12 @@ class GenerateImage extends Operation {
139
141
  }
140
142
 
141
143
  try {
142
- const pixel = Jimp.rgbaToInt(red, green, blue, alpha);
144
+ const pixel = rgbaToInt(red, green, blue, alpha);
143
145
  image.setPixelColor(pixel, x, y);
144
146
  } catch (err) {
145
- throw new OperationError(`Error while generating image from pixel values. (${err})`);
147
+ throw new OperationError(
148
+ `Error while generating image from pixel values. (${err})`,
149
+ );
146
150
  }
147
151
  }
148
152
  }
@@ -151,11 +155,15 @@ class GenerateImage extends Operation {
151
155
  if (isWorkerEnvironment())
152
156
  self.sendStatusMessage("Scaling image...");
153
157
 
154
- image.scaleToFit(width*scale, height*scale, Jimp.RESIZE_NEAREST_NEIGHBOR);
158
+ image.scaleToFit({
159
+ w: width * scale,
160
+ h: height * scale,
161
+ mode: ResizeStrategy.NEAREST_NEIGHBOR,
162
+ });
155
163
  }
156
164
 
157
165
  try {
158
- const imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
166
+ const imageBuffer = await image.getBuffer(JimpMime.png);
159
167
  return imageBuffer.buffer;
160
168
  } catch (err) {
161
169
  throw new OperationError(`Error generating image. (${err})`);
@@ -178,7 +186,6 @@ class GenerateImage extends Operation {
178
186
 
179
187
  return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
180
188
  }
181
-
182
189
  }
183
190
 
184
191
  export default GenerateImage;
@@ -9,13 +9,12 @@ import OperationError from "../errors/OperationError.mjs";
9
9
  import { isImage } from "../lib/FileType.mjs";
10
10
  import { toBase64 } from "../lib/Base64.mjs";
11
11
  import { isWorkerEnvironment } from "../Utils.mjs";
12
- import Jimp from "jimp/es/index.js";
12
+ import { Jimp, JimpMime } from "jimp";
13
13
 
14
14
  /**
15
15
  * Image Brightness / Contrast operation
16
16
  */
17
17
  class ImageBrightnessContrast extends Operation {
18
-
19
18
  /**
20
19
  * ImageBrightnessContrast constructor
21
20
  */
@@ -35,15 +34,15 @@ class ImageBrightnessContrast extends Operation {
35
34
  type: "number",
36
35
  value: 0,
37
36
  min: -100,
38
- max: 100
37
+ max: 100,
39
38
  },
40
39
  {
41
40
  name: "Contrast",
42
41
  type: "number",
43
42
  value: 0,
44
43
  min: -100,
45
- max: 100
46
- }
44
+ max: 100,
45
+ },
47
46
  ];
48
47
  }
49
48
 
@@ -77,14 +76,16 @@ class ImageBrightnessContrast extends Operation {
77
76
  }
78
77
 
79
78
  let imageBuffer;
80
- if (image.getMIME() === "image/gif") {
81
- imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
79
+ if (image.mime === "image/gif") {
80
+ imageBuffer = await image.getBuffer(JimpMime.png);
82
81
  } else {
83
- imageBuffer = await image.getBufferAsync(Jimp.AUTO);
82
+ imageBuffer = await image.getBuffer(image.mime);
84
83
  }
85
84
  return imageBuffer.buffer;
86
85
  } catch (err) {
87
- throw new OperationError(`Error adjusting image brightness or contrast. (${err})`);
86
+ throw new OperationError(
87
+ `Error adjusting image brightness or contrast. (${err})`,
88
+ );
88
89
  }
89
90
  }
90
91
 
@@ -104,7 +105,6 @@ class ImageBrightnessContrast extends Operation {
104
105
 
105
106
  return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
106
107
  }
107
-
108
108
  }
109
109
 
110
110
  export default ImageBrightnessContrast;
@@ -9,13 +9,12 @@ import OperationError from "../errors/OperationError.mjs";
9
9
  import { isImage } from "../lib/FileType.mjs";
10
10
  import { toBase64 } from "../lib/Base64.mjs";
11
11
  import { isWorkerEnvironment } from "../Utils.mjs";
12
- import Jimp from "jimp/es/index.js";
12
+ import { Jimp, JimpMime } from "jimp";
13
13
 
14
14
  /**
15
15
  * Image Filter operation
16
16
  */
17
17
  class ImageFilter extends Operation {
18
-
19
18
  /**
20
19
  * ImageFilter constructor
21
20
  */
@@ -33,11 +32,8 @@ class ImageFilter extends Operation {
33
32
  {
34
33
  name: "Filter type",
35
34
  type: "option",
36
- value: [
37
- "Greyscale",
38
- "Sepia"
39
- ]
40
- }
35
+ value: ["Greyscale", "Sepia"],
36
+ },
41
37
  ];
42
38
  }
43
39
 
@@ -60,7 +56,11 @@ class ImageFilter extends Operation {
60
56
  }
61
57
  try {
62
58
  if (isWorkerEnvironment())
63
- self.sendStatusMessage("Applying " + filterType.toLowerCase() + " filter to image...");
59
+ self.sendStatusMessage(
60
+ "Applying " +
61
+ filterType.toLowerCase() +
62
+ " filter to image...",
63
+ );
64
64
  if (filterType === "Greyscale") {
65
65
  image.greyscale();
66
66
  } else {
@@ -68,14 +68,16 @@ class ImageFilter extends Operation {
68
68
  }
69
69
 
70
70
  let imageBuffer;
71
- if (image.getMIME() === "image/gif") {
72
- imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
71
+ if (image.mime === "image/gif") {
72
+ imageBuffer = await image.getBuffer(JimpMime.png);
73
73
  } else {
74
- imageBuffer = await image.getBufferAsync(Jimp.AUTO);
74
+ imageBuffer = await image.getBuffer(image.mime);
75
75
  }
76
76
  return imageBuffer.buffer;
77
77
  } catch (err) {
78
- throw new OperationError(`Error applying filter to image. (${err})`);
78
+ throw new OperationError(
79
+ `Error applying filter to image. (${err})`,
80
+ );
79
81
  }
80
82
  }
81
83
 
@@ -95,7 +97,6 @@ class ImageFilter extends Operation {
95
97
 
96
98
  return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
97
99
  }
98
-
99
100
  }
100
101
 
101
102
  export default ImageFilter;
@@ -9,13 +9,12 @@ import OperationError from "../errors/OperationError.mjs";
9
9
  import { isImage } from "../lib/FileType.mjs";
10
10
  import { toBase64 } from "../lib/Base64.mjs";
11
11
  import { isWorkerEnvironment } from "../Utils.mjs";
12
- import Jimp from "jimp/es/index.js";
12
+ import { Jimp, JimpMime } from "jimp";
13
13
 
14
14
  /**
15
15
  * Image Hue/Saturation/Lightness operation
16
16
  */
17
17
  class ImageHueSaturationLightness extends Operation {
18
-
19
18
  /**
20
19
  * ImageHueSaturationLightness constructor
21
20
  */
@@ -24,7 +23,8 @@ class ImageHueSaturationLightness extends Operation {
24
23
 
25
24
  this.name = "Image Hue/Saturation/Lightness";
26
25
  this.module = "Image";
27
- this.description = "Adjusts the hue / saturation / lightness (HSL) values of an image.";
26
+ this.description =
27
+ "Adjusts the hue / saturation / lightness (HSL) values of an image.";
28
28
  this.infoURL = "";
29
29
  this.inputType = "ArrayBuffer";
30
30
  this.outputType = "ArrayBuffer";
@@ -35,22 +35,22 @@ class ImageHueSaturationLightness extends Operation {
35
35
  type: "number",
36
36
  value: 0,
37
37
  min: -360,
38
- max: 360
38
+ max: 360,
39
39
  },
40
40
  {
41
41
  name: "Saturation",
42
42
  type: "number",
43
43
  value: 0,
44
44
  min: -100,
45
- max: 100
45
+ max: 100,
46
46
  },
47
47
  {
48
48
  name: "Lightness",
49
49
  type: "number",
50
50
  value: 0,
51
51
  min: -100,
52
- max: 100
53
- }
52
+ max: 100,
53
+ },
54
54
  ];
55
55
  }
56
56
 
@@ -76,43 +76,45 @@ class ImageHueSaturationLightness extends Operation {
76
76
  if (hue !== 0) {
77
77
  if (isWorkerEnvironment())
78
78
  self.sendStatusMessage("Changing image hue...");
79
- image.colour([
79
+ image.color([
80
80
  {
81
81
  apply: "hue",
82
- params: [hue]
83
- }
82
+ params: [hue],
83
+ },
84
84
  ]);
85
85
  }
86
86
  if (saturation !== 0) {
87
87
  if (isWorkerEnvironment())
88
88
  self.sendStatusMessage("Changing image saturation...");
89
- image.colour([
89
+ image.color([
90
90
  {
91
91
  apply: "saturate",
92
- params: [saturation]
93
- }
92
+ params: [saturation],
93
+ },
94
94
  ]);
95
95
  }
96
96
  if (lightness !== 0) {
97
97
  if (isWorkerEnvironment())
98
98
  self.sendStatusMessage("Changing image lightness...");
99
- image.colour([
99
+ image.color([
100
100
  {
101
101
  apply: "lighten",
102
- params: [lightness]
103
- }
102
+ params: [lightness],
103
+ },
104
104
  ]);
105
105
  }
106
106
 
107
107
  let imageBuffer;
108
- if (image.getMIME() === "image/gif") {
109
- imageBuffer = await image.getBufferAsync(Jimp.MIME_PNG);
108
+ if (image.mime === "image/gif") {
109
+ imageBuffer = await image.getBuffer(JimpMime.png);
110
110
  } else {
111
- imageBuffer = await image.getBufferAsync(Jimp.AUTO);
111
+ imageBuffer = await image.getBuffer(image.mime);
112
112
  }
113
113
  return imageBuffer.buffer;
114
114
  } catch (err) {
115
- throw new OperationError(`Error adjusting image hue / saturation / lightness. (${err})`);
115
+ throw new OperationError(
116
+ `Error adjusting image hue / saturation / lightness. (${err})`,
117
+ );
116
118
  }
117
119
  }
118
120