Edit an image - external libraries
laserwolve
Posts: 34
I'm wanting to edit an image via Daz script. Specifically, I'm looking to alpha clamp, and crop to visible pixels. Due to the alpha value bug in Daz's version of Qt, I don't think I can extract the data I need from Daz script alone.
A double-nested loop to work on each pixel of an image is also super slow:
(var x = 0; x != img.width; x++) { (var y = 0; y != img.height; y++) { // manipulate each pixel here }}
Has anyone tried to use an external JavaScript library in Daz Script? Is it possible? Can I use something like babeljs to sanitize a library to ES5? I'm going to try and do this with this library: https://github.com/image-js/image-js
Comments
I've been trying this. I've got a setup that works somewhat. I can transpile TypeScript/ES6 down to ES5. With one click I can transpile and run my script.
I've tried using 3rd party libraries. As a test I tried `mathjs` but the output script still contains some features that Qt doesn't like. Specifically the use of 'Symbol' and unicode variable names. I haven't looked further into this, as at this point I haven't had a need yet.
I've attached my environment. Run `npm install`, write your script in `src/index.ts` and run `npm run execute`.
I also made my own type definitions that I haven't included. I also found this project that seems to have some: https://github.com/siblount/JzSense
You will likely need to convince babel to do more transpiling or polyfilling to get every library to work. Please post back here if you manage to make some progress there