Browse Source

Change ops to use ArrayBuffer instead of byteArray

j433866 6 years ago
parent
commit
e44a22e143

+ 12 - 11
src/core/operations/AddTextToImage.mjs

@@ -25,8 +25,8 @@ class AddTextToImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Adds text onto an image.<br><br>Text can be horizontally or vertically aligned, or the position can be manually specified.<br>Variants of the Roboto font face are available in any size or colour.<br><br>Note: This may cause a degradation in image quality, especially when using font sizes larger than 72.";
         this.description = "Adds text onto an image.<br><br>Text can be horizontally or vertically aligned, or the position can be manually specified.<br>Variants of the Roboto font face are available in any size or colour.<br><br>Note: This may cause a degradation in image quality, especially when using font sizes larger than 72.";
         this.infoURL = "";
         this.infoURL = "";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -102,7 +102,7 @@ class AddTextToImage extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
@@ -120,13 +120,13 @@ class AddTextToImage extends Operation {
         let xPos = args[3],
         let xPos = args[3],
             yPos = args[4];
             yPos = args[4];
 
 
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -147,7 +147,7 @@ class AddTextToImage extends Operation {
                     fontsMap.Roboto = fonts[0];
                     fontsMap.Roboto = fonts[0];
                     fontsMap["Roboto Black"] = fonts[1];
                     fontsMap["Roboto Black"] = fonts[1];
                     fontsMap["Roboto Mono"] = fonts[2];
                     fontsMap["Roboto Mono"] = fonts[2];
-                    fontsMap["Roboto Slab"] = fonts[3]
+                    fontsMap["Roboto Slab"] = fonts[3];
                 });
                 });
 
 
 
 
@@ -248,7 +248,7 @@ class AddTextToImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error adding text to image. (${err})`);
             throw new OperationError(`Error adding text to image. (${err})`);
         }
         }
@@ -257,18 +257,19 @@ class AddTextToImage extends Operation {
     /**
     /**
      * Displays the blurred image using HTML for web apps
      * Displays the blurred image using HTML for web apps
      *
      *
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/BlurImage.mjs

@@ -26,8 +26,8 @@ class BlurImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Applies a blur effect to the image.<br><br>Gaussian blur is much slower than fast blur, but produces better results.";
         this.description = "Applies a blur effect to the image.<br><br>Gaussian blur is much slower than fast blur, but produces better results.";
         this.infoURL = "https://wikipedia.org/wiki/Gaussian_blur";
         this.infoURL = "https://wikipedia.org/wiki/Gaussian_blur";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -45,20 +45,20 @@ class BlurImage extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
         const [blurAmount, blurType] = args;
         const [blurAmount, blurType] = args;
 
 
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -82,7 +82,7 @@ class BlurImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error blurring image. (${err})`);
             throw new OperationError(`Error blurring image. (${err})`);
         }
         }
@@ -91,18 +91,19 @@ class BlurImage extends Operation {
     /**
     /**
      * Displays the blurred image using HTML for web apps
      * Displays the blurred image using HTML for web apps
      *
      *
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/ContainImage.mjs

@@ -25,8 +25,8 @@ class ContainImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Scales an image to the specified width and height, maintaining the aspect ratio. The image may be letterboxed.";
         this.description = "Scales an image to the specified width and height, maintaining the aspect ratio. The image may be letterboxed.";
         this.infoURL = "";
         this.infoURL = "";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -82,7 +82,7 @@ class ContainImage extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
@@ -106,13 +106,13 @@ class ContainImage extends Operation {
             "Bottom": jimp.VERTICAL_ALIGN_BOTTOM
             "Bottom": jimp.VERTICAL_ALIGN_BOTTOM
         };
         };
 
 
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -133,7 +133,7 @@ class ContainImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error containing image. (${err})`);
             throw new OperationError(`Error containing image. (${err})`);
         }
         }
@@ -141,18 +141,19 @@ class ContainImage extends Operation {
 
 
     /**
     /**
      * Displays the contained image using HTML for web apps
      * Displays the contained image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 12 - 11
src/core/operations/ConvertImageFormat.mjs

@@ -25,8 +25,8 @@ class ConvertImageFormat extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Converts an image between different formats. Supported formats:<br><ul><li>Joint Photographic Experts Group (JPEG)</li><li>Portable Network Graphics (PNG)</li><li>Bitmap (BMP)</li><li>Tagged Image File Format (TIFF)</li></ul><br>Note: GIF files are supported for input, but cannot be outputted.";
         this.description = "Converts an image between different formats. Supported formats:<br><ul><li>Joint Photographic Experts Group (JPEG)</li><li>Portable Network Graphics (PNG)</li><li>Bitmap (BMP)</li><li>Tagged Image File Format (TIFF)</li></ul><br>Note: GIF files are supported for input, but cannot be outputted.";
         this.infoURL = "https://wikipedia.org/wiki/Image_file_formats";
         this.infoURL = "https://wikipedia.org/wiki/Image_file_formats";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -69,7 +69,7 @@ class ConvertImageFormat extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
@@ -93,12 +93,12 @@ class ConvertImageFormat extends Operation {
 
 
         const mime = formatMap[format];
         const mime = formatMap[format];
 
 
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file format.");
             throw new OperationError("Invalid file format.");
         }
         }
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error opening image file. (${err})`);
             throw new OperationError(`Error opening image file. (${err})`);
         }
         }
@@ -114,7 +114,7 @@ class ConvertImageFormat extends Operation {
             }
             }
 
 
             const imageBuffer = await image.getBufferAsync(mime);
             const imageBuffer = await image.getBufferAsync(mime);
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error converting image format. (${err})`);
             throw new OperationError(`Error converting image format. (${err})`);
         }
         }
@@ -123,18 +123,19 @@ class ConvertImageFormat extends Operation {
     /**
     /**
      * Displays the converted image using HTML for web apps
      * Displays the converted image using HTML for web apps
      *
      *
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
-            throw new OperationError("Invalid image type.");
+            throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/CoverImage.mjs

@@ -25,8 +25,8 @@ class CoverImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Scales the image to the given width and height, keeping the aspect ratio. The image may be clipped.";
         this.description = "Scales the image to the given width and height, keeping the aspect ratio. The image may be clipped.";
         this.infoURL = "";
         this.infoURL = "";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -77,7 +77,7 @@ class CoverImage extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
@@ -101,13 +101,13 @@ class CoverImage extends Operation {
             "Bottom": jimp.VERTICAL_ALIGN_BOTTOM
             "Bottom": jimp.VERTICAL_ALIGN_BOTTOM
         };
         };
 
 
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -121,7 +121,7 @@ class CoverImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error covering image. (${err})`);
             throw new OperationError(`Error covering image. (${err})`);
         }
         }
@@ -129,18 +129,19 @@ class CoverImage extends Operation {
 
 
     /**
     /**
      * Displays the covered image using HTML for web apps
      * Displays the covered image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/CropImage.mjs

@@ -25,8 +25,8 @@ class CropImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Crops an image to the specified region, or automatically crops edges.<br><br><b><u>Autocrop</u></b><br>Automatically crops same-colour borders from the image.<br><br><u>Autocrop tolerance</u><br>A percentage value for the tolerance of colour difference between pixels.<br><br><u>Only autocrop frames</u><br>Only crop real frames (all sides must have the same border)<br><br><u>Symmetric autocrop</u><br>Force autocrop to be symmetric (top/bottom and left/right are cropped by the same amount)<br><br><u>Autocrop keep border</u><br>The number of pixels of border to leave around the image.";
         this.description = "Crops an image to the specified region, or automatically crops edges.<br><br><b><u>Autocrop</u></b><br>Automatically crops same-colour borders from the image.<br><br><u>Autocrop tolerance</u><br>A percentage value for the tolerance of colour difference between pixels.<br><br><u>Only autocrop frames</u><br>Only crop real frames (all sides must have the same border)<br><br><u>Symmetric autocrop</u><br>Force autocrop to be symmetric (top/bottom and left/right are cropped by the same amount)<br><br><u>Autocrop keep border</u><br>The number of pixels of border to leave around the image.";
         this.infoURL = "https://wikipedia.org/wiki/Cropping_(image)";
         this.infoURL = "https://wikipedia.org/wiki/Cropping_(image)";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -86,19 +86,19 @@ class CropImage extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
         const [xPos, yPos, width, height, autocrop, autoTolerance, autoFrames, autoSymmetric, autoBorder] = args;
         const [xPos, yPos, width, height, autocrop, autoTolerance, autoFrames, autoSymmetric, autoBorder] = args;
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -122,7 +122,7 @@ class CropImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error cropping image. (${err})`);
             throw new OperationError(`Error cropping image. (${err})`);
         }
         }
@@ -130,18 +130,19 @@ class CropImage extends Operation {
 
 
     /**
     /**
      * Displays the cropped image using HTML for web apps
      * Displays the cropped image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/DitherImage.mjs

@@ -25,25 +25,25 @@ class DitherImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Apply a dither effect to an image.";
         this.description = "Apply a dither effect to an image.";
         this.infoURL = "https://wikipedia.org/wiki/Dither";
         this.infoURL = "https://wikipedia.org/wiki/Dither";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [];
         this.args = [];
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -58,7 +58,7 @@ class DitherImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error applying dither to image. (${err})`);
             throw new OperationError(`Error applying dither to image. (${err})`);
         }
         }
@@ -66,18 +66,19 @@ class DitherImage extends Operation {
 
 
     /**
     /**
      * Displays the dithered image using HTML for web apps
      * Displays the dithered image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/FlipImage.mjs

@@ -25,8 +25,8 @@ class FlipImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Flips an image along its X or Y axis.";
         this.description = "Flips an image along its X or Y axis.";
         this.infoURL = "";
         this.infoURL = "";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -38,19 +38,19 @@ class FlipImage extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
         const [flipAxis] = args;
         const [flipAxis] = args;
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid input file type.");
             throw new OperationError("Invalid input file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -72,7 +72,7 @@ class FlipImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error flipping image. (${err})`);
             throw new OperationError(`Error flipping image. (${err})`);
         }
         }
@@ -80,18 +80,19 @@ class FlipImage extends Operation {
 
 
     /**
     /**
      * Displays the flipped image using HTML for web apps
      * Displays the flipped image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/ImageBrightnessContrast.mjs

@@ -25,8 +25,8 @@ class ImageBrightnessContrast extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Adjust the brightness or contrast of an image.";
         this.description = "Adjust the brightness or contrast of an image.";
         this.infoURL = "";
         this.infoURL = "";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -47,19 +47,19 @@ class ImageBrightnessContrast extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
         const [brightness, contrast] = args;
         const [brightness, contrast] = args;
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -81,7 +81,7 @@ class ImageBrightnessContrast extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error adjusting image brightness or contrast. (${err})`);
             throw new OperationError(`Error adjusting image brightness or contrast. (${err})`);
         }
         }
@@ -89,18 +89,19 @@ class ImageBrightnessContrast extends Operation {
 
 
     /**
     /**
      * Displays the image using HTML for web apps
      * Displays the image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/ImageFilter.mjs

@@ -25,8 +25,8 @@ class ImageFilter extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Applies a greyscale or sepia filter to an image.";
         this.description = "Applies a greyscale or sepia filter to an image.";
         this.infoURL = "";
         this.infoURL = "";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -41,19 +41,19 @@ class ImageFilter extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
         const [filterType] = args;
         const [filterType] = args;
-        if (!isImage(input)){
+        if (!isImage(new Uint8Array(input))){
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -72,7 +72,7 @@ class ImageFilter extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error applying filter to image. (${err})`);
             throw new OperationError(`Error applying filter to image. (${err})`);
         }
         }
@@ -80,18 +80,19 @@ class ImageFilter extends Operation {
 
 
     /**
     /**
      * Displays the blurred image using HTML for web apps
      * Displays the blurred image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/ImageHueSaturationLightness.mjs

@@ -25,8 +25,8 @@ class ImageHueSaturationLightness extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Adjusts the hue / saturation / lightness (HSL) values of an image.";
         this.description = "Adjusts the hue / saturation / lightness (HSL) values of an image.";
         this.infoURL = "";
         this.infoURL = "";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -54,20 +54,20 @@ class ImageHueSaturationLightness extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
         const [hue, saturation, lightness] = args;
         const [hue, saturation, lightness] = args;
 
 
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -109,7 +109,7 @@ class ImageHueSaturationLightness extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error adjusting image hue / saturation / lightness. (${err})`);
             throw new OperationError(`Error adjusting image hue / saturation / lightness. (${err})`);
         }
         }
@@ -117,18 +117,19 @@ class ImageHueSaturationLightness extends Operation {
 
 
     /**
     /**
      * Displays the image using HTML for web apps
      * Displays the image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 }
 }
 
 

+ 11 - 10
src/core/operations/ImageOpacity.mjs

@@ -25,8 +25,8 @@ class ImageOpacity extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Adjust the opacity of an image.";
         this.description = "Adjust the opacity of an image.";
         this.infoURL = "";
         this.infoURL = "";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -40,19 +40,19 @@ class ImageOpacity extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
         const [opacity] = args;
         const [opacity] = args;
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -67,7 +67,7 @@ class ImageOpacity extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error changing image opacity. (${err})`);
             throw new OperationError(`Error changing image opacity. (${err})`);
         }
         }
@@ -75,18 +75,19 @@ class ImageOpacity extends Operation {
 
 
     /**
     /**
      * Displays the image using HTML for web apps
      * Displays the image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/InvertImage.mjs

@@ -25,25 +25,25 @@ class InvertImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Invert the colours of an image.";
         this.description = "Invert the colours of an image.";
         this.infoURL = "";
         this.infoURL = "";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [];
         this.args = [];
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid input file format.");
             throw new OperationError("Invalid input file format.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -58,7 +58,7 @@ class InvertImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error inverting image. (${err})`);
             throw new OperationError(`Error inverting image. (${err})`);
         }
         }
@@ -66,18 +66,19 @@ class InvertImage extends Operation {
 
 
     /**
     /**
      * Displays the inverted image using HTML for web apps
      * Displays the inverted image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/NormaliseImage.mjs

@@ -25,25 +25,25 @@ class NormaliseImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Normalise the image colours.";
         this.description = "Normalise the image colours.";
         this.infoURL = "";
         this.infoURL = "";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType=  "html";
         this.presentType=  "html";
         this.args = [];
         this.args = [];
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error opening image file. (${err})`);
             throw new OperationError(`Error opening image file. (${err})`);
         }
         }
@@ -57,7 +57,7 @@ class NormaliseImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error normalising image. (${err})`);
             throw new OperationError(`Error normalising image. (${err})`);
         }
         }
@@ -65,18 +65,19 @@ class NormaliseImage extends Operation {
 
 
     /**
     /**
      * Displays the normalised image using HTML for web apps
      * Displays the normalised image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 4 - 4
src/core/operations/ParseQRCode.mjs

@@ -25,7 +25,7 @@ class ParseQRCode extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Reads an image file and attempts to detect and read a Quick Response (QR) code from the image.<br><br><u>Normalise Image</u><br>Attempts to normalise the image before parsing it to improve detection of a QR code.";
         this.description = "Reads an image file and attempts to detect and read a Quick Response (QR) code from the image.<br><br><u>Normalise Image</u><br>Attempts to normalise the image before parsing it to improve detection of a QR code.";
         this.infoURL = "https://wikipedia.org/wiki/QR_code";
         this.infoURL = "https://wikipedia.org/wiki/QR_code";
-        this.inputType = "byteArray";
+        this.inputType = "ArrayBuffer";
         this.outputType = "string";
         this.outputType = "string";
         this.args = [
         this.args = [
             {
             {
@@ -37,7 +37,7 @@ class ParseQRCode extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {string}
      * @returns {string}
      */
      */
@@ -45,7 +45,7 @@ class ParseQRCode extends Operation {
         const [normalise] = args;
         const [normalise] = args;
 
 
         // Make sure that the input is an image
         // Make sure that the input is an image
-        if (!isImage(input)) throw new OperationError("Invalid file type.");
+        if (!isImage(new Uint8Array(input))) throw new OperationError("Invalid file type.");
 
 
         let image = input;
         let image = input;
 
 
@@ -57,7 +57,7 @@ class ParseQRCode extends Operation {
             // Makes the image greyscale
             // Makes the image greyscale
             // Converts image to a JPEG
             // Converts image to a JPEG
             image = await new Promise((resolve, reject) => {
             image = await new Promise((resolve, reject) => {
-                jimp.read(Buffer.from(input))
+                jimp.read(input)
                     .then(image => {
                     .then(image => {
                         image
                         image
                             .rgba(false)
                             .rgba(false)

+ 11 - 10
src/core/operations/ResizeImage.mjs

@@ -25,8 +25,8 @@ class ResizeImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Resizes an image to the specified width and height values.";
         this.description = "Resizes an image to the specified width and height values.";
         this.infoURL = "https://wikipedia.org/wiki/Image_scaling";
         this.infoURL = "https://wikipedia.org/wiki/Image_scaling";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -67,7 +67,7 @@ class ResizeImage extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
@@ -86,13 +86,13 @@ class ResizeImage extends Operation {
             "Bezier": jimp.RESIZE_BEZIER
             "Bezier": jimp.RESIZE_BEZIER
         };
         };
 
 
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -116,7 +116,7 @@ class ResizeImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error resizing image. (${err})`);
             throw new OperationError(`Error resizing image. (${err})`);
         }
         }
@@ -124,18 +124,19 @@ class ResizeImage extends Operation {
 
 
     /**
     /**
      * Displays the resized image using HTML for web apps
      * Displays the resized image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 11 - 10
src/core/operations/RotateImage.mjs

@@ -25,8 +25,8 @@ class RotateImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Rotates an image by the specified number of degrees.";
         this.description = "Rotates an image by the specified number of degrees.";
         this.infoURL = "";
         this.infoURL = "";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -38,20 +38,20 @@ class RotateImage extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
         const [degrees] = args;
         const [degrees] = args;
 
 
-        if (!isImage(input)) {
+        if (!isImage(new Uint8Array(input))) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -66,7 +66,7 @@ class RotateImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error rotating image. (${err})`);
             throw new OperationError(`Error rotating image. (${err})`);
         }
         }
@@ -74,18 +74,19 @@ class RotateImage extends Operation {
 
 
     /**
     /**
      * Displays the rotated image using HTML for web apps
      * Displays the rotated image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }

+ 12 - 11
src/core/operations/SharpenImage.mjs

@@ -26,8 +26,8 @@ class SharpenImage extends Operation {
         this.module = "Image";
         this.module = "Image";
         this.description = "Sharpens an image (Unsharp mask)";
         this.description = "Sharpens an image (Unsharp mask)";
         this.infoURL = "https://wikipedia.org/wiki/Unsharp_masking";
         this.infoURL = "https://wikipedia.org/wiki/Unsharp_masking";
-        this.inputType = "byteArray";
-        this.outputType = "byteArray";
+        this.inputType = "ArrayBuffer";
+        this.outputType = "ArrayBuffer";
         this.presentType = "html";
         this.presentType = "html";
         this.args = [
         this.args = [
             {
             {
@@ -54,20 +54,20 @@ class SharpenImage extends Operation {
     }
     }
 
 
     /**
     /**
-     * @param {byteArray} input
+     * @param {ArrayBuffer} input
      * @param {Object[]} args
      * @param {Object[]} args
      * @returns {byteArray}
      * @returns {byteArray}
      */
      */
     async run(input, args) {
     async run(input, args) {
         const [radius, amount, threshold] = args;
         const [radius, amount, threshold] = args;
 
 
-        if (!isImage(input)){
+        if (!isImage(new Uint8Array(input))){
             throw new OperationError("Invalid file type.");
             throw new OperationError("Invalid file type.");
         }
         }
 
 
         let image;
         let image;
         try {
         try {
-            image = await jimp.read(Buffer.from(input));
+            image = await jimp.read(input);
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error loading image. (${err})`);
             throw new OperationError(`Error loading image. (${err})`);
         }
         }
@@ -140,7 +140,7 @@ class SharpenImage extends Operation {
             } else {
             } else {
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
                 imageBuffer = await image.getBufferAsync(jimp.AUTO);
             }
             }
-            return [...imageBuffer];
+            return imageBuffer.buffer;
         } catch (err) {
         } catch (err) {
             throw new OperationError(`Error sharpening image. (${err})`);
             throw new OperationError(`Error sharpening image. (${err})`);
         }
         }
@@ -148,18 +148,19 @@ class SharpenImage extends Operation {
 
 
     /**
     /**
      * Displays the sharpened image using HTML for web apps
      * Displays the sharpened image using HTML for web apps
-     * @param {byteArray} data
+     * @param {ArrayBuffer} data
      * @returns {html}
      * @returns {html}
      */
      */
     present(data) {
     present(data) {
-        if (!data.length) return "";
+        if (!data.byteLength) return "";
+        const dataArray = new Uint8Array(data);
 
 
-        const type = isImage(data);
+        const type = isImage(dataArray);
         if (!type) {
         if (!type) {
-            throw new OperationError("Invalid image type.");
+            throw new OperationError("Invalid file type.");
         }
         }
 
 
-        return `<img src="data:${type};base64,${toBase64(data)}">`;
+        return `<img src="data:${type};base64,${toBase64(dataArray)}">`;
     }
     }
 
 
 }
 }