mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Tidied up 'Split Colour Channels' operation and added 'Multimedia' category
This commit is contained in:
parent
02b92c7977
commit
8b533e9893
5 changed files with 50 additions and 38 deletions
|
@ -2,6 +2,9 @@
|
||||||
All major and minor version changes will be documented in this file. Details of patch-level version changes can be found in [commit messages](https://github.com/gchq/CyberChef/commits/master).
|
All major and minor version changes will be documented in this file. Details of patch-level version changes can be found in [commit messages](https://github.com/gchq/CyberChef/commits/master).
|
||||||
|
|
||||||
|
|
||||||
|
### [8.18.0] - 2018-12-26
|
||||||
|
- 'Split Colour Channels' operation added [@artemisbot] | [#449]
|
||||||
|
|
||||||
### [8.17.0] - 2018-12-25
|
### [8.17.0] - 2018-12-25
|
||||||
- 'Generate QR Code' and 'Parse QR Code' operations added [@j433866] | [#448]
|
- 'Generate QR Code' and 'Parse QR Code' operations added [@j433866] | [#448]
|
||||||
|
|
||||||
|
@ -82,6 +85,7 @@ All major and minor version changes will be documented in this file. Details of
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[8.18.0]: https://github.com/gchq/CyberChef/releases/tag/v8.18.0
|
||||||
[8.17.0]: https://github.com/gchq/CyberChef/releases/tag/v8.17.0
|
[8.17.0]: https://github.com/gchq/CyberChef/releases/tag/v8.17.0
|
||||||
[8.16.0]: https://github.com/gchq/CyberChef/releases/tag/v8.16.0
|
[8.16.0]: https://github.com/gchq/CyberChef/releases/tag/v8.16.0
|
||||||
[8.15.0]: https://github.com/gchq/CyberChef/releases/tag/v8.15.0
|
[8.15.0]: https://github.com/gchq/CyberChef/releases/tag/v8.15.0
|
||||||
|
@ -150,3 +154,4 @@ All major and minor version changes will be documented in this file. Details of
|
||||||
[#443]: https://github.com/gchq/CyberChef/pull/443
|
[#443]: https://github.com/gchq/CyberChef/pull/443
|
||||||
[#446]: https://github.com/gchq/CyberChef/pull/446
|
[#446]: https://github.com/gchq/CyberChef/pull/446
|
||||||
[#448]: https://github.com/gchq/CyberChef/pull/448
|
[#448]: https://github.com/gchq/CyberChef/pull/448
|
||||||
|
[#449]: https://github.com/gchq/CyberChef/pull/449
|
||||||
|
|
|
@ -347,9 +347,17 @@
|
||||||
"Detect File Type",
|
"Detect File Type",
|
||||||
"Scan for Embedded Files",
|
"Scan for Embedded Files",
|
||||||
"Remove EXIF",
|
"Remove EXIF",
|
||||||
"Extract EXIF",
|
"Extract EXIF"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Multimedia",
|
||||||
|
"ops": [
|
||||||
"Render Image",
|
"Render Image",
|
||||||
"Play Media"
|
"Play Media",
|
||||||
|
"Remove EXIF",
|
||||||
|
"Extract EXIF",
|
||||||
|
"Split Colour Channels"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -366,10 +374,6 @@
|
||||||
"Generate QR Code",
|
"Generate QR Code",
|
||||||
"Parse QR Code",
|
"Parse QR Code",
|
||||||
"Haversine distance",
|
"Haversine distance",
|
||||||
"Render Image",
|
|
||||||
"Remove EXIF",
|
|
||||||
"Extract EXIF",
|
|
||||||
"Split Colour Channels",
|
|
||||||
"Numberwang",
|
"Numberwang",
|
||||||
"XKCD Random Number"
|
"XKCD Random Number"
|
||||||
]
|
]
|
||||||
|
|
|
@ -24,25 +24,12 @@ class SplitColourChannels extends Operation {
|
||||||
|
|
||||||
this.name = "Split Colour Channels";
|
this.name = "Split Colour Channels";
|
||||||
this.module = "Image";
|
this.module = "Image";
|
||||||
this.description = "Splits given image into its red, green and blue colour channels.";
|
this.description = "Splits the given image into its red, green and blue colour channels.";
|
||||||
this.infoURL = "https://en.wikipedia.org/wiki/Channel_(digital_image)";
|
this.infoURL = "https://wikipedia.org/wiki/Channel_(digital_image)";
|
||||||
this.inputType = "byteArray";
|
this.inputType = "byteArray";
|
||||||
this.outputType = "List<File>";
|
this.outputType = "List<File>";
|
||||||
this.presentType = "html";
|
this.presentType = "html";
|
||||||
this.args = [
|
this.args = [];
|
||||||
/* Example arguments. See the project wiki for full details.
|
|
||||||
{
|
|
||||||
name: "First arg",
|
|
||||||
type: "string",
|
|
||||||
value: "Don't Panic"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: "Second arg",
|
|
||||||
type: "number",
|
|
||||||
value: 42
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -55,18 +42,22 @@ class SplitColourChannels extends Operation {
|
||||||
// Make sure that the input is an image
|
// Make sure that the input is an image
|
||||||
if (type && type.mime.indexOf("image") === 0) {
|
if (type && type.mime.indexOf("image") === 0) {
|
||||||
const parsedImage = await jimp.read(Buffer.from(input));
|
const parsedImage = await jimp.read(Buffer.from(input));
|
||||||
|
|
||||||
const red = new Promise(async (resolve, reject) => {
|
const red = new Promise(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const split = parsedImage.clone()
|
const split = parsedImage
|
||||||
|
.clone()
|
||||||
.color([
|
.color([
|
||||||
{apply: "blue", params: [-255]},
|
{apply: "blue", params: [-255]},
|
||||||
{apply: "green", params: [-255]}
|
{apply: "green", params: [-255]}
|
||||||
]).getBufferAsync(jimp.MIME_PNG);
|
])
|
||||||
|
.getBufferAsync(jimp.MIME_PNG);
|
||||||
resolve(new File([new Uint8Array((await split).values())], "red.png", {type: "image/png"}));
|
resolve(new File([new Uint8Array((await split).values())], "red.png", {type: "image/png"}));
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
reject(new OperationError(`Could not split red channel: ${err}`));
|
reject(new OperationError(`Could not split red channel: ${err}`));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const green = new Promise(async (resolve, reject) => {
|
const green = new Promise(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const split = parsedImage.clone()
|
const split = parsedImage.clone()
|
||||||
|
@ -79,6 +70,7 @@ class SplitColourChannels extends Operation {
|
||||||
reject(new OperationError(`Could not split green channel: ${err}`));
|
reject(new OperationError(`Could not split green channel: ${err}`));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const blue = new Promise(async (resolve, reject) => {
|
const blue = new Promise(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const split = parsedImage
|
const split = parsedImage
|
||||||
|
@ -91,6 +83,7 @@ class SplitColourChannels extends Operation {
|
||||||
reject(new OperationError(`Could not split blue channel: ${err}`));
|
reject(new OperationError(`Could not split blue channel: ${err}`));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return await Promise.all([red, green, blue]);
|
return await Promise.all([red, green, blue]);
|
||||||
} else {
|
} else {
|
||||||
throw new OperationError("Invalid file type.");
|
throw new OperationError("Invalid file type.");
|
||||||
|
|
|
@ -74,7 +74,6 @@ import "./tests/operations/SeqUtils";
|
||||||
import "./tests/operations/SetDifference";
|
import "./tests/operations/SetDifference";
|
||||||
import "./tests/operations/SetIntersection";
|
import "./tests/operations/SetIntersection";
|
||||||
import "./tests/operations/SetUnion";
|
import "./tests/operations/SetUnion";
|
||||||
//import "./tests/operations/SplitColourChannels";
|
|
||||||
import "./tests/operations/StrUtils";
|
import "./tests/operations/StrUtils";
|
||||||
import "./tests/operations/SymmetricDifference";
|
import "./tests/operations/SymmetricDifference";
|
||||||
import "./tests/operations/TextEncodingBruteForce";
|
import "./tests/operations/TextEncodingBruteForce";
|
||||||
|
@ -84,6 +83,9 @@ import "./tests/operations/Magic";
|
||||||
import "./tests/operations/ParseTLV";
|
import "./tests/operations/ParseTLV";
|
||||||
import "./tests/operations/Media";
|
import "./tests/operations/Media";
|
||||||
|
|
||||||
|
// Cannot test operations that use the File type yet
|
||||||
|
//import "./tests/operations/SplitColourChannels";
|
||||||
|
|
||||||
let allTestsPassing = true;
|
let allTestsPassing = true;
|
||||||
const testStatusCounts = {
|
const testStatusCounts = {
|
||||||
total: 0,
|
total: 0,
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue