You're sending JSON:

return res.status(200).json(imgProcessed)

That means you're sending text, not binary data.

You probably wanted to send just the data:

return res.status(200).send(imgProcessed)
// --------------------^^^^

I'm assuming imgProcessed is a Buffer; if not you want to make it one. See the Express.js documentation for send. (It will handle sending the Content-Type: application/octet-stream header for you when you give it a Buffer.)

Answer from T.J. Crowder on Stack Overflow
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Uint8ClampedArray › Uint8ClampedArray
Uint8ClampedArray() constructor - JavaScript - MDN Web Docs
July 10, 2025 - // From a length const uint8c = ... y = new Uint8ClampedArray(x); console.log(y[0]); // 21 // From an ArrayBuffer const buffer = new ArrayBuffer(8); const z = new Uint8ClampedArray(buffer, 1, 4); console.log(z.byteOffset); // 1 // From an iterable const iterable = (function* ...
🌐
MDN
mdn2.netlify.app › en-us › docs › web › javascript › reference › global_objects › uint8clampedarray › uint8clampedarray
Uint8ClampedArray() constructor - JavaScript | MDN
February 18, 2022 - // From a length var uintc8 = new ... console.log(y[0]); // 21 // From an ArrayBuffer var buffer = new ArrayBuffer(8); var z = new Uint8ClampedArray(buffer, 1, 4); // From an iterable var iterable = function*(){ yield* [1,2,3]; ...
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Uint8ClampedArray
Uint8ClampedArray - JavaScript - MDN Web Docs
July 10, 2025 - The Uint8ClampedArray typed array represents an array of 8-bit unsigned integers clamped to 0–255. The contents are initialized to 0 unless initialization data is explicitly provided. Once established, you can reference elements in the array using the object's methods, or using standard array ...
🌐
Stack Overflow
stackoverflow.com › questions › 50545135 › why-is-conversion-from-an-untyped-array-to-uint8clampedarray-so-slow › 52192816
Why is conversion from an untyped array to Uint8ClampedArray so slow?
May 26, 2018 - So to render the shaded result, ... = pixelateMatrix(frameBuffer); // shading = ~30ms (kinda slow) outputBuffer = new Uint8ClampedArray(outputBufferRaw); // conversion = ~100ms (very slow)...
🌐
MDN
mdn2.netlify.app › en-us › docs › web › javascript › reference › global_objects › uint8clampedarray
Uint8ClampedArray - JavaScript | MDN
February 18, 2022 - Returns the length (in bytes) of the Uint8ClampedArray from the start of its ArrayBuffer.
🌐
JavaScripture
javascripture.com › Uint8ClampedArray
Uint8ClampedArray JavaScript API
Gets and sets the element in this at index. index should be between 0 and this.length - 1. Setting an element to a value less than 0 will store 0 and greater than 255 will store 255 in the array. ... Returns the underlying buffer for this Uint8ClampedArray.
Find elsewhere
🌐
GitHub
github.com › mdn › content › blob › main › files › en-us › web › javascript › reference › global_objects › uint8clampedarray › uint8clampedarray › index.md
content/files/en-us/web/javascript/reference/global_objects/uint8clampedarray/uint8clampedarray/index.md at main · mdn/content
const y = new Uint8ClampedArray(x); console.log(y[0]); // 21 · · // From an ArrayBuffer · const buffer = new ArrayBuffer(8); const z = new Uint8ClampedArray(buffer, 1, 4); console.log(z.byteOffset); // 1 · · // From an iterable · const ...
Author: mdn
🌐
GitHub
github.com › lovell › sharp › issues › 549
Pipe buffer image data into Uint8ClampedArray format · Issue #549 · lovell/sharp
August 22, 2016 - The .data property of the ImageData object appears to be a Uint8ClampedArray that reads [r1, g1, b1, a1, r2, g2, b2, a2.....] Looking at the pattern, every fourth number is 255 which makes sense as none of the image is transparent at all. I am trying to get this to work in Node.JS in a similar fashion, except I am getting my image data from a buffer generated by smarp see code below:
Author: lovell
🌐
Salesforce
documentation.b2c.commercecloud.salesforce.com › DOC3 › topic › com.demandware.dochelp › DWAPI › scriptapi › html › api › class_TopLevel_Uint8ClampedArray.html
Class Uint8ClampedArray | Salesforce B2C Developer Documentation Resources
... Creates an empty array. ... Creates an array with the given element count. ... Creates an array as a copy of the passed typed array. ... Creates an array as a copy of the passed array. Uint8ClampedArray(buffer : ArrayBuffer, byteOffset : Number, length : Number)
🌐
ReScript
rescript-lang.org › docs › manual › api › stdlib › uint8clampedarray
Stdlib.Uint8clampedarray | ReScript API
fromBufferToEnd creates a Uint8ClampedArray from an ArrayBuffer.t, starting at a particular offset and continuing through to the end. See TypedArray constructor on MDN · Note: This is a potentially unsafe operation. Ensure the buffer is large enough and only accessed within its bounds.
🌐
GeeksforGeeks
geeksforgeeks.org › javascript-uint8clampedarray-from-method
JavaScript Uint8ClampedArray.from() Method | GeeksforGeeks
July 11, 2023 - The Uint8ClampedArray represents an array of 8-bit unsigned integers clamped to 0-255. If a value is specified that is not in the range of [0, 255], 0, or 255 will be set instead; if the specified value is not an integer, the nearest integer will be set.
🌐
UDN Web Docs
udn.realityripple.com › docs › Mozilla › js-ctypes › Using_js-ctypes › Working_with_ArrayBuffers
Working with ArrayBuffers - UDN Web Docs: MDN Backup
// pixelBuffer is a pointer to ... imgHeight = 400; var myImgDat = new ImageData(imgWidth, imgHeight); One method is to get into a js-ctypes array, and then set it into the ImageData, as illustrated by the following code example....
🌐
Unibo
lia.disi.unibo.it › materiale › JS › developer.mozilla.org › en-US › docs › Web › JavaScript › Reference › Global_Objects › Uint8ClampedArray.html
Uint8ClampedArray - JavaScript | MDN
// From a length var uintc8 = new ... console.log(y[0]); // 21 // From an ArrayBuffer var buffer = new ArrayBuffer(8); var z = new Uint8ClampedArray(buffer, 1, 4); Desktop · Mobile · JavaScript typed arrays · ArrayBuffer ...
🌐
Bun
bun.sh › guides › binary › arraybuffer-to-typedarray
Convert an ArrayBuffer to a Uint8Array - Bun
const buffer = new ArrayBuffer(64); const arr = new Uint8Array(buffer, 0, 16); // view first 16 bytes
🌐
Google Groups
groups.google.com › g › emscripten-discuss › c › -Ac-XNpVIL8
Converting a memory location to an ArrayBuffer
November 11, 2016 - var dim = 1080; var buffer = Module.createBitmap(dim); var c = document.getElementById("bitmap"); var ctx = c.getContext("2d"); var imgData = ctx.createImageData(dim,dim); for (var i = 0; i < dim*dim*4; i++) { imgData.data[i] = Module.HEAPU8[buffer+i]; } ctx.putImageData(imgData, 0, 0) What ...
🌐
GitHub
github.com › stdlib-js › array-uint8c
GitHub - stdlib-js/array-uint8c: Uint8ClampedArray. · GitHub
Copies array elements to a new array with the same underlying data type as the host array. var arr1 = new Uint8ClampedArray( [ 1, 2, 3 ] ); var arr2 = arr1.slice(); var bool = ( arr1 === arr2 ); // returns false bool = ( arr1.buffer === arr2.buffer ...
Author: stdlib-js