mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-20 14:56:19 -04:00
Add status messages for image operations
This commit is contained in:
parent
833c1cd98f
commit
4a7ea469d4
8 changed files with 24 additions and 3 deletions
|
@ -99,6 +99,8 @@ class CropImage extends Operation {
|
|||
}
|
||||
|
||||
const image = await jimp.read(Buffer.from(input));
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
self.sendStatusMessage("Cropping image...");
|
||||
if (autocrop) {
|
||||
image.autocrop({
|
||||
tolerance: (autoTolerance / 100),
|
||||
|
|
|
@ -41,6 +41,8 @@ class DitherImage extends Operation {
|
|||
|
||||
if (type && type.mime.indexOf("image") === 0){
|
||||
const image = await jimp.read(Buffer.from(input));
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
self.sendStatusMessage("Applying dither to image...");
|
||||
image.dither565();
|
||||
const imageBuffer = await image.getBufferAsync(jimp.AUTO);
|
||||
return [...imageBuffer];
|
||||
|
|
|
@ -51,6 +51,8 @@ class FlipImage extends Operation {
|
|||
|
||||
const image = await jimp.read(Buffer.from(input));
|
||||
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
self.sendStatusMessage("Flipping image...");
|
||||
switch (flipAxis){
|
||||
case "Horizontal":
|
||||
image.flip(true, false);
|
||||
|
|
|
@ -59,8 +59,16 @@ class ImageBrightnessContrast extends Operation {
|
|||
}
|
||||
|
||||
const image = await jimp.read(Buffer.from(input));
|
||||
image.brightness(brightness / 100);
|
||||
image.contrast(contrast / 100);
|
||||
if (brightness !== 0) {
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
self.sendStatusMessage("Changing image brightness...");
|
||||
image.brightness(brightness / 100);
|
||||
}
|
||||
if (contrast !== 0) {
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
self.sendStatusMessage("Changing image contrast...");
|
||||
image.contrast(contrast / 100);
|
||||
}
|
||||
|
||||
const imageBuffer = await image.getBufferAsync(jimp.AUTO);
|
||||
return [...imageBuffer];
|
||||
|
|
|
@ -53,7 +53,8 @@ class ImageFilter extends Operation {
|
|||
}
|
||||
|
||||
const image = await jimp.read(Buffer.from(input));
|
||||
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
self.sendStatusMessage("Applying " + filterType.toLowerCase() + " filter to image...");
|
||||
if (filterType === "Greyscale") {
|
||||
image.greyscale();
|
||||
} else {
|
||||
|
|
|
@ -52,6 +52,8 @@ class ImageOpacity extends Operation {
|
|||
}
|
||||
|
||||
const image = await jimp.read(Buffer.from(input));
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
self.sendStatusMessage("Changing image opacity...");
|
||||
image.opacity(opacity / 100);
|
||||
|
||||
const imageBuffer = await image.getBufferAsync(jimp.MIME_PNG);
|
||||
|
|
|
@ -42,6 +42,8 @@ class InvertImage extends Operation {
|
|||
throw new OperationError("Invalid input file format.");
|
||||
}
|
||||
const image = await jimp.read(Buffer.from(input));
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
self.sendStatusMessage("Inverting image...");
|
||||
image.invert();
|
||||
const imageBuffer = await image.getBufferAsync(jimp.AUTO);
|
||||
return [...imageBuffer];
|
||||
|
|
|
@ -48,6 +48,8 @@ class RotateImage extends Operation {
|
|||
|
||||
if (type && type.mime.indexOf("image") === 0){
|
||||
const image = await jimp.read(Buffer.from(input));
|
||||
if (ENVIRONMENT_IS_WORKER())
|
||||
self.sendStatusMessage("Rotating image...");
|
||||
image.rotate(degrees);
|
||||
const imageBuffer = await image.getBufferAsync(jimp.AUTO);
|
||||
return [...imageBuffer];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue