Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

import failed in Electron #1

Open
YuanTian1991 opened this issue Sep 18, 2021 · 3 comments
Open

import failed in Electron #1

YuanTian1991 opened this issue Sep 18, 2021 · 3 comments

Comments

@YuanTian1991
Copy link

Hi:

Thanks for develop this tool, I want to transfer some j2c buffer into image buffer (eventually to base64 for img display). I tried to add this module into my electron project, but a error show up.

abort(CompileError: WebAssembly.instantiate(): expected magic word 00 61 73 6d, found 3c 21 44 4f @+0). Build with -s ASSERTIONS=1 for more info.

image

Do you have any suggestions on how I can fix this? Also, do you know other javascript (node) tool that can do the j2c-image-base64 conversion?

Many Thanks!

@palemieux
Copy link
Contributor

3c 21 44 4f translates to <!DO, so it looks like you were trying to load (using WebAssembly.instantiateStreaming()?) an HTML file (that starts with <!DOCTYPE HTML...) instead of a WebAssembly file.

@YuanTian1991
Copy link
Author

Thanks for your previous answer, yes I finally found it's my electron setting up thing. However, I am still struggle to get openhtjs work in my electron App.

For example, I installed library with npm, then encountered problem to read:

I put this line in my react file:

import { Decoder } from "openht/dist/HT";

Then encounter this error.

Failed to compile.
[0] 
[0] ./node_modules/openht/dist/HT.js 16:17
[0] Module parse failed: Cannot use keyword 'await' outside an async function (16:17)
[0] File was processed with these loaders:
[0]  * ./node_modules/babel-loader/lib/index.js
[0] You may need an additional loader to handle the result of these loaders.
[0] | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
[0] | import makeHTCodec from './HT_internal.js';
[0] > const ht_codec = await makeHTCodec();
[0] | 
[0] | ht_codec.HTDecoder.prototype.decodeToRGBAArray = function (array_buffer, decompositionLevel = 0) {

Could you provide an example, like load library, read a jp2 image, convert it into jpg. (Actually, my initial plan is to directly convert jp2 binary to base64 string of jpg, but never mind, I can't get any js solution work for JP2 conversation now).

@YuanTian1991
Copy link
Author

Sorry, I just found your example here. Will try to follow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants