Giter Site home page Giter Site logo

Comments (7)

silvia-odwyer avatar silvia-odwyer commented on June 12, 2024

@coreyward Hi Corey! Thanks for opening this issue. It's mentioned that you're using photon, however there is a separate library photon-node for Node environments, linked here. Could you try this and see if it works? If not, could you provide the image or base64 string also, as it would help diagnose the issue. Thanks very much! πŸ˜„ πŸ‘

from photon.

coreyward avatar coreyward commented on June 12, 2024

@silvia-odwyer Oops that was just a typo in my post. I'm using photon-node in my code. I don't think the base64 string matters here as it happens even with this 3-line example going the other direction:

const photon = require("@silvia-odwyer/photon-node")
const img = new photon.PhotonImage([], 10, 10)
img.get_base64()

For reference, this occurred with every base64 string I tried, and I verified syntax on several by doing pbpaste | base64 --decode > test.jpg and confirming that the file operated like normal (e.g. in Preview/QuickLook).

from photon.

coreyward avatar coreyward commented on June 12, 2024

Here's a CodeSandbox example demonstrating the issue. It actually seems to work fine when creating the image from the PNG data, but the JPG fails.

This is the source of the PNG. I convert it to JPEG using some built-in routine in Finder, resulting in the image attached here, for reference:

Red_Square_(2x2_Pixel)

from photon.

silvia-odwyer avatar silvia-odwyer commented on June 12, 2024

@coreyward Thanks very much for the CodeSandbox example, it's much appreciated! πŸ‘ I've taken a look at the issue, and it seems to be linked to Issue #120. The rayon feature seems to be causing the bug in relation to creating jpeg images from base64.

To fix this, I've just published a new build. Could you update your photon-node dependency to 0.3.2 and let me know if it solves the issue? Thanks very much! πŸ˜„ πŸ‘

from photon.

coreyward avatar coreyward commented on June 12, 2024

Thank you! It looks like this allows const img = photon.PhotonImage.new_from_base64(redSquareJpgB64); to succeed πŸŽ‰ , but calling img.get_image_data() or photon.get_image_data(img) on the result results in the same β€œunreachable” error. Calling photon.grayscale(img) like the guide shows results in β€œUncaught: Error: recursive use of an object detected which would lead to unsafe aliasing in rust”. Am I doing something wrong here?

from photon.

silvia-odwyer avatar silvia-odwyer commented on June 12, 2024

Hi Corey,
I've just ran the example mentioned in the guide here, and it worked as expected. However when I included a line to get the image data, it did result in an unreachable error. I'll have to investigate why that is, although creating png/jpg images with base64 and writing the output is all working okay for me.

If you can't seem to apply effects etc, just include a code snippet and I'll try help out! πŸ˜„ πŸ‘

from photon.

allthesignals avatar allthesignals commented on June 12, 2024

Hi there, I'm also seeing this via get_image_data using ^0.3.3:

    const base64 = fs.readFileSync(imagePath, { encoding: 'base64' });
    const data = base64.replace(/^data:image\/(png|jpg);base64,/, "");
    const phtn_img = photon.PhotonImage.new_from_base64(data);
    photon.laplace(phtn_img)
    phtn_img.get_image_data();

RuntimeError: unreachable
at wasm://wasm/0052704a:wasm-function[1043]:0xf0618
at wasm://wasm/0052704a:wasm-function[1159]:0xf5558
at wasm://wasm/0052704a:wasm-function[1359]:0xfb0dc
at wasm://wasm/0052704a:wasm-function[1520]:0xfdf67
at wasm://wasm/0052704a:wasm-function[1204]:0xf6eec
at wasm://wasm/0052704a:wasm-function[1157]:0xf5437
at PhotonImage.get_image_data (/Users/mattgardner/archive-dol-arpa-income-verification/app/node_modules/@silvia-odwyer/photon-node/photon_rs.js:3905:24)

EDIT: Okay... I think this is a buried error over needing to apply another .replace(/^data:image\/(png|jpg);base64,/, "");

from photon.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.