Giter Club home page Giter Club logo

Comments (12)

bartbutenaers avatar bartbutenaers commented on July 17, 2024

Ok, seemed that the require statements returns a function, so I had to add () to call it:

const charlsJs = require('@cornerstonejs/codec-charls')();

So that is solved.
But stuck again... When I call this:

decoder.decode();

Then I get the exception that I should pass 0 arguments to this function, instead of 0 arguments. So not sure what that is about. That exception is raised here:

image

Thanks!

from charls-js.

chafey avatar chafey commented on July 17, 2024

Hi Bart - I don’t know off the top of my head, did you try out the node example in this repo:

https://github.com/chafey/charls-js/blob/master/test/node/index.js

from charls-js.

bartbutenaers avatar bartbutenaers commented on July 17, 2024

Hey Chris,
Thanks for your fast response!
Yes indeed I used that example to start with this library:

// ' buffer' contains my jpeg encoded image
var decoder = new charlsJs.JpegLSDecoder();
var decoderBuffer = decoder.getEncodedBuffer(buffer.length);
decoderBuffer.set(buffer);
decoder.decode();

I have debugged this over and over and over again, but don't see what I am doing wrong.
The decode method expects zero parameters:

image

And I pass zero arguments, I still i keep getting that error...
Moreover I am getting nuts: since arguments length is 0, how on earth can I arrive within the if(arguments.length !== 0) condition. Don't see what is wrong...

from charls-js.

chafey avatar chafey commented on July 17, 2024

Any update on this issue? One possible cause of this is the node version you are using. I just ran it on my mac using Node v16.3.0:
√ node (master) % npm run test

[email protected] test
node index.js

Decode of ../fixtures/jls/CT1.JLS took 5.369811 ms
frameInfo = { width: 512, height: 512, bitsPerSample: 16, componentCount: 1 }
decoded length = 524288
Decode of ../fixtures/jls/CT2.JLS took 5.340883 ms
frameInfo = { width: 512, height: 512, bitsPerSample: 16, componentCount: 1 }
decoded length = 524288
Decode of ../../extern/charls/test/lena8b.jls took 6.267212000000001 ms
frameInfo = { width: 512, height: 512, bitsPerSample: 8, componentCount: 1 }
decoded length = 262144
Encode of ../fixtures/raw/CT2.RAW took 6.631587000000001 ms
encoded length= 115504
√ node (master) % node --version
v16.13.0

from charls-js.

bartbutenaers avatar bartbutenaers commented on July 17, 2024

Hi @chafey,

Sorry for the delay. Long (unplanned) hours this week at work.
Yes indeed your test works fine here:

image

And the speed is quite impressive!!
So it won't be my older NodeJs version I assume.
But of course I tested your repo, which I downloaded via a git clone.
However I need an npm package (which I can use as a dependency), so I need to get it working via the '@cornerstonejs/codec-charls package.

I will need to do some more tests. Will keep you updated.
If you have any other tips or things that I could try, don't hesitate to let me know. All help is welcome!

from charls-js.

chafey avatar chafey commented on July 17, 2024

I don't know what is different about the cornerstonejs/codec-charls package (it was based on this repo but I didn't create it) - did you try posting an issue there? If you can't get it to working, you can always use git submodule to reference this repo

from charls-js.

bartbutenaers avatar bartbutenaers commented on July 17, 2024

The weird thing is that the npm module shows links to your repository:

image

So I thought that your perhaps somehow were working together...

And I also assumed that he just published your repo, without any changes.
Because when I do this:

require.resolve('@cornerstonejs/codec-charls')

I get this result:
'C:\Users\Gebruiker\.node-red\node_modules\@cornerstonejs\codec-charls\dist\charlsjs.js'
So it seemed to me that he used the same charlsjs.js file as in your example above.
But perhaps not...

from charls-js.

chafey avatar chafey commented on July 17, 2024

That is weird - I am guessing just an error when they copied the code over. I was certainly aware of the effort but did not work on it

from charls-js.

bartbutenaers avatar bartbutenaers commented on July 17, 2024

Ok I have tried to narrow down the problem a bit more.

  1. I download this example image (which I had choosen randomly last week) to a file.

  2. I change your index.js test to load this file:

    decode('C:\\temp\\Team_Queerala.jpg');
    
  3. Then I run your example:

    node --trace_uncaught C:\Users\Gebruiker\charls-js\test\node\index.js
    
  4. Which shows the decoding exception (which is a number?):

    5671952
    Thrown at:
        at C:\Users\Gebruiker\charls-js\dist\charlsjs.js:1:1852
        at emit (events.js:314:20)
        at internal/process/execution.js:165:25
    

I don't see anything wrong with that jpeg image. Hopefully it makes more sense to you...

from charls-js.

chafey avatar chafey commented on July 17, 2024

This library is for decoding JPEG-LS images. The image you linked is JPEG baseline (different). What are you trying to do...?

from charls-js.

bartbutenaers avatar bartbutenaers commented on July 17, 2024

Oh what a mistake then ;-(
To be honest, I have never thought about the fact that there are multiple types of jpegs...
I am a contributor for the open source Node-RED IOT dataflow framework.
Would like to create two nodes (as you can see in the screenshots in this discussion): one for decoding jpeg images from IP camera's, and another one for encoding jpeg images.
Pure javascript is too slow, and nativie libraries give a lot of build headaches on various platforms. So wanted to try whether wasm was fast enough...

from charls-js.

bartbutenaers avatar bartbutenaers commented on July 17, 2024

Apologies for the confusion, and for wasting your precious time!!!
I will close this issue and look for another library.
Thanks a lot and keep up the good work!!

from charls-js.

Related Issues (1)

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.