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

Imported directly into Angular 12 but cannot run any functions? __wbindgen_malloc? #102

Open
gregmarut opened this issue Aug 24, 2021 · 4 comments

Comments

@gregmarut
Copy link

import * as photon from "@silvia-odwyer/photon";

let imageData = photon.base64_to_image(base64Contents).get_image_data();
core.js:6479 ERROR TypeError: Cannot read property '__wbindgen_malloc' of undefined
    at Module.base64_to_image (photon_rs_bg.js:1739)
@silvia-odwyer
Copy link
Owner

@gregmarut Sorry to hear about this! I've found this repo, which integrates a wasm module with Angular 8, it might potentially help you out hopefully! But, do let me know if isn't working 👍 I haven't used the module with Angular, I only have examples for React in the repository currently. Hopefully the repo I've linked will help you out that said ✅

@gregmarut
Copy link
Author

Thanks, I will take a look.

@phellmayr1
Copy link

@gregmarut were you able to make it work with angular? I am currently also fighting with that.
(I get some errors like e.g. Exception: ReferenceError: Cannot access 'PhotonImage' before initialization at Module.PhotonImage)
Thank you :)

@gregmarut
Copy link
Author

@phellmayr1 no but I ended up solving my needs by going with a different library instead. I am using a different library to load an image in a rust WASM. Hopefully this helps

[dependencies]
base64 = "0.13.0"
image = { version = "0.23.14", default-features = false, features = ["jpeg", "png", "gif"] }
//decode the base64 encoded image to bytes
let buffer = base64::decode(base64Image);
let bytes = buffer.unwrap();

//load the image from memory
let mut img = image::load_from_memory(bytes.as_slice()).unwrap();

//convert the image to an RGBA image
img = ImageRgba8(img.to_rgba8());

//extract the pixels from the image
let pixels = img.to_bytes();

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

3 participants