Execute fails with 'TypeError: Cannot read property 'buffer' of undefined [...]'
Sidewinder53 opened this issue · comments
When executing two simple image manipulation commands in a browser environment, the ExecuteResult
object will contain an error and only the result of the first command is provided.
Code:
import { buildInputFile, execute } from 'https://cdn.jsdelivr.net/npm/wasm-imagemagick/dist/bundles/magickApi.js';
let DoMagickCall = async function () {
let result = await execute({
inputFiles: [await buildInputFile('./locked-out.png', 'frame.png')],
commands: [
'convert frame.png -rotate 90 image2.png',
'convert image2.png -rotate 45 image3.png'
]
});
console.log(result);
}
DoMagickCall();
Result:
result:
errors: Array(2)
0: undefined
1: "TypeError: Cannot read property 'buffer' of undefined, exit code: 1, stderr: "
exitCode: 1
outputFiles: Array(1)
0: {name: "image2.png", buffer: Uint8Array(67478)}
results: Array(2)
0: {outputFiles: Array(1), stdout: Array(0), stderr: Array(0), exitCode: 0, errors: Array(1)}
1: {stderr: Array(0), stdout: Array(0), outputFiles: Array(0), exitCode: 1, errors: Array(1)}
Download test files to reproduce
Any ideas why this is happening? Thanks for your help!
Just tried the zip with a static server works fine for me. I'm on Chrome, which browser are you using ?
Unfortunately, I don't get the same result. Please note that the image appearing in the DOM does not mean that the operation succeeded. You have to open the developer tools and check the first object in the console which will output these errors:
Microsoft Edge (Chromium) 77.0.211.3
The result
object will always contain only one output in outputFiles
, and that is the result of the first command.
@cancerberoSgx 5e2351b breaks the rotate example.
1.2.3 which is before your change https://knicknic.github.io/wasm-imagemagick/index.1.2.3.html works
1.2.4 which included your change is broken https://knicknic.github.io/wasm-imagemagick/index.1.2.4.html
Ensure you have adblock disabled when going to repo pages.
What is the recommended fix for this? I'm on the latest version 1.2.7, and cannot execute multiple commands in a row at all, regardless of the command.
@charlesj currently this bug exists, as you can see there was a purposed bug fix, however this caused a break in other usage of the api.
Someone needs to code a fix that doesn’t cause the regression so both issues are fixed. Either that or if the regression introduced doesn’t bother you, use 1.2.4, which I guess would work for your usecase.
fixed in d0213c8 use 1.2.8 for fix
please reopen if https://www.npmjs.com/package/wasm-imagemagick/v/1.2.8 doesn't work for you.