fix: handle empty generate image mode
This commit is contained in:
parent
0e50d32ec5
commit
64b63d86bc
@ -76,6 +76,10 @@ class GenerateImage extends Operation {
|
||||
|
||||
const bytesPerPixel = bytePerPixelMap[mode];
|
||||
|
||||
if (bytesPerPixel === undefined) {
|
||||
throw new OperationError(`Unsupported Mode: (${mode})`);
|
||||
}
|
||||
|
||||
if (bytesPerPixel > 0 && input.length % bytesPerPixel !== 0) {
|
||||
throw new OperationError(
|
||||
`Number of bytes is not a divisor of ${bytesPerPixel}`,
|
||||
|
||||
@ -45,6 +45,17 @@ TestRegister.addTests([
|
||||
{ op: "Render Image", args: ["Base64"] }
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Generate Image: empty mode",
|
||||
input: "",
|
||||
expectedOutput: "Unsupported Mode: ()",
|
||||
recipeConfig: [
|
||||
{
|
||||
op: "Generate Image",
|
||||
args: ["", 8, 64]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name: "Extract EXIF: nothing",
|
||||
input: "",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user