diff --git a/src/core/operations/GenerateImage.mjs b/src/core/operations/GenerateImage.mjs index 56b5798a..c276213d 100644 --- a/src/core/operations/GenerateImage.mjs +++ b/src/core/operations/GenerateImage.mjs @@ -74,12 +74,12 @@ class GenerateImage extends Operation { Bits: 1 / 8, }; - const bytesPerPixel = bytePerPixelMap[mode]; - - if (bytesPerPixel === undefined) { + if (!Object.hasOwn(bytePerPixelMap, mode)) { throw new OperationError(`Unsupported Mode: (${mode})`); } + const bytesPerPixel = bytePerPixelMap[mode]; + if (bytesPerPixel > 0 && input.length % bytesPerPixel !== 0) { throw new OperationError( `Number of bytes is not a divisor of ${bytesPerPixel}`,