Tidied up 'Split Colour Channels' operation and added 'Multimedia' category

This commit is contained in:
n1474335 2018-12-26 16:33:10 +00:00
parent 02b92c7977
commit 8b533e9893
5 changed files with 50 additions and 38 deletions

View file

@ -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).
### [8.18.0] - 2018-12-26
- 'Split Colour Channels' operation added [@artemisbot] | [#449]
### [8.17.0] - 2018-12-25
- '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.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
@ -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
[#446]: https://github.com/gchq/CyberChef/pull/446
[#448]: https://github.com/gchq/CyberChef/pull/448
[#449]: https://github.com/gchq/CyberChef/pull/449

View file

@ -347,9 +347,17 @@
"Detect File Type",
"Scan for Embedded Files",
"Remove EXIF",
"Extract EXIF",
"Extract EXIF"
]
},
{
"name": "Multimedia",
"ops": [
"Render Image",
"Play Media"
"Play Media",
"Remove EXIF",
"Extract EXIF",
"Split Colour Channels"
]
},
{
@ -366,10 +374,6 @@
"Generate QR Code",
"Parse QR Code",
"Haversine distance",
"Render Image",
"Remove EXIF",
"Extract EXIF",
"Split Colour Channels",
"Numberwang",
"XKCD Random Number"
]

View file

@ -24,25 +24,12 @@ class SplitColourChannels extends Operation {
this.name = "Split Colour Channels";
this.module = "Image";
this.description = "Splits given image into its red, green and blue colour channels.";
this.infoURL = "https://en.wikipedia.org/wiki/Channel_(digital_image)";
this.description = "Splits the given image into its red, green and blue colour channels.";
this.infoURL = "https://wikipedia.org/wiki/Channel_(digital_image)";
this.inputType = "byteArray";
this.outputType = "List<File>";
this.presentType = "html";
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
}
*/
];
this.args = [];
}
/**
@ -55,18 +42,22 @@ class SplitColourChannels extends Operation {
// Make sure that the input is an image
if (type && type.mime.indexOf("image") === 0) {
const parsedImage = await jimp.read(Buffer.from(input));
const red = new Promise(async (resolve, reject) => {
try {
const split = parsedImage.clone()
const split = parsedImage
.clone()
.color([
{apply: "blue", 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"}));
} catch (err) {
reject(new OperationError(`Could not split red channel: ${err}`));
}
});
const green = new Promise(async (resolve, reject) => {
try {
const split = parsedImage.clone()
@ -79,6 +70,7 @@ class SplitColourChannels extends Operation {
reject(new OperationError(`Could not split green channel: ${err}`));
}
});
const blue = new Promise(async (resolve, reject) => {
try {
const split = parsedImage
@ -91,6 +83,7 @@ class SplitColourChannels extends Operation {
reject(new OperationError(`Could not split blue channel: ${err}`));
}
});
return await Promise.all([red, green, blue]);
} else {
throw new OperationError("Invalid file type.");

View file

@ -74,7 +74,6 @@ import "./tests/operations/SeqUtils";
import "./tests/operations/SetDifference";
import "./tests/operations/SetIntersection";
import "./tests/operations/SetUnion";
//import "./tests/operations/SplitColourChannels";
import "./tests/operations/StrUtils";
import "./tests/operations/SymmetricDifference";
import "./tests/operations/TextEncodingBruteForce";
@ -84,6 +83,9 @@ import "./tests/operations/Magic";
import "./tests/operations/ParseTLV";
import "./tests/operations/Media";
// Cannot test operations that use the File type yet
//import "./tests/operations/SplitColourChannels";
let allTestsPassing = true;
const testStatusCounts = {
total: 0,

File diff suppressed because one or more lines are too long