1
0
mirror of synced 2024-11-28 16:40:49 +01:00

Tidied up 'Generate Image' operation

This commit is contained in:
n1474335 2020-03-13 16:35:19 +00:00
parent 032c7f529a
commit 1a5dae76c2
2 changed files with 10 additions and 11 deletions

View File

@ -394,8 +394,8 @@
"name": "Multimedia",
"ops": [
"Render Image",
"Generate Image",
"Play Media",
"Generate Image",
"Optical Character Recognition",
"Remove EXIF",
"Extract EXIF",

View File

@ -25,9 +25,9 @@ class GenerateImage extends Operation {
this.name = "Generate Image";
this.module = "Image";
this.description = "Generate an Image using the input as pixel values.";
this.description = "Generates an image using the input as pixel values.";
this.infoURL = "";
this.inputType = "byteArray";
this.inputType = "ArrayBuffer";
this.outputType = "ArrayBuffer";
this.presentType = "html";
this.args = [
@ -42,7 +42,7 @@ class GenerateImage extends Operation {
"value": 8,
},
{
"name": "Pixels per Row",
"name": "Pixels per row",
"type": "number",
"value": 64,
}
@ -55,9 +55,8 @@ class GenerateImage extends Operation {
* @returns {ArrayBuffer}
*/
async run(input, args) {
const mode = args[0];
const scale = args[1];
const width = args[2];
const [mode, scale, width] = args;
input = new Uint8Array(input);
if (scale <= 0) {
throw new OperationError("Pixel Scale Factor needs to be > 0");
@ -85,7 +84,7 @@ class GenerateImage extends Operation {
const image = await new jimp(width, height, (err, image) => {});
if (isWorkerEnvironment())
self.sendStatusMessage("Generate image from data...");
self.sendStatusMessage("Generating image from data...");
if (mode === "Bits") {
let index = 0;
@ -150,7 +149,7 @@ class GenerateImage extends Operation {
if (scale !== 1) {
if (isWorkerEnvironment())
self.sendStatusMessage("Scale image...");
self.sendStatusMessage("Scaling image...");
image.scaleToFit(width*scale, height*scale, jimp.RESIZE_NEAREST_NEIGHBOR);
}