image-sequencer
image-sequencer copied to clipboard
Text overlay now works in nodeJS
Concerns #1378
Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!
- [x] tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with
npm test - [x] code is in uniquely-named feature branch and has no merge conflicts
- [x] PR is descriptively titled
- [x] ask
@publiclab/is-reviewersfor help, in a comment below - [x] Insert-step functionality is working correct as expected.
We're happy to help you get this ready -- don't be afraid to ask for help, and don't be discouraged if your tests fail at first!
If tests do fail, click on the red X to learn why by reading the logs.
Please be sure you've reviewed our contribution guidelines at https://publiclab.org/contributing-to-public-lab-software Please make sure to get at least two reviews before asking for merging the PR as that would make the PR more reliable on our part Thanks!
Codecov Report
Merging #1518 into main will increase coverage by
0.09%. The diff coverage is100%.
@@ Coverage Diff @@
## main #1518 +/- ##
==========================================
+ Coverage 66.64% 66.74% +0.09%
==========================================
Files 130 130
Lines 2674 2682 +8
Branches 430 432 +2
==========================================
+ Hits 1782 1790 +8
Misses 892 892
| Impacted Files | Coverage Δ | |
|---|---|---|
| src/modules/AddQR/Module.js | 100% <ø> (ø) |
:arrow_up: |
| src/modules/DrawRectangle/DrawRectangle.js | 100% <100%> (ø) |
:arrow_up: |
| src/modules/Gradient/Module.js | 100% <100%> (ø) |
:arrow_up: |
Waiting for the tests....
Please fix the conflicts. Thanks!
I am facing problem in running it in nodeJS after #1533, It is using Image element, but for some reason when I imported it from jsdom, the onload event is not firing and when I used ctx.putImageData instead of ctx.drawImage, text overlay stopped working for GIfs :confused: @ataata107 Why did you removed putImageData and used drawImage instead is there any major difference?
Is it not working currently?
No, it isn't
#1533 was a dangerous PR. We need to do a followup soon and fix some things.
Yes! It also broke #1546, It was working fine before #1533, after that it is not resizing the image
Hmm. Would you like to open an issue for this? Also mention some things which broke.
Issue opened! #1547
@blurry-x-face I had to do that because putting pixels (of gifs) onto canvas was tampering the data. But instead if I used the source url it worked fine
Ok, so after A LOT OF DEBUGGING, I finally found the reason why this was having problem running in node, turns out the problem was this https://github.com/publiclab/image-sequencer/blob/f6d53163b92b8678903956647cddf65b020e0b56/src/modules/_nomodule/PixelManipulation.js#L292 generateOutput was getting called beore the extramanipulation was completed so generateOutput was getting run twice!! one time in pixelManipulation and one time in extramanipulation https://github.com/publiclab/image-sequencer/blob/f6d53163b92b8678903956647cddf65b020e0b56/src/modules/TextOverlay/Module.js#L15-L17 Therefore in node the output was generated from the first generateOutput call hence the image was not getting changed because the way image is generated from cli is that it generates the image the first time generateOutput is called, so to fix this what we can do is:
if (options.extraManipulation){
frames[f] = options.extraManipulation(framePix, setRenderState, generateOutput) || framePix; // extraManipulation is used to manipulate each pixel individually.
perFrameShape = frames[f].shape;
}else
generateOutput();
And then each module that uses extramanipulation we have to call generateOutput after extramanipulation is completed like we do in text-overlay! :weary: https://github.com/publiclab/image-sequencer/blob/f6d53163b92b8678903956647cddf65b020e0b56/src/modules/TextOverlay/Module.js#L15-L17 I'll open an issue regarding this and make a PR for it super soon! @jywarren @HarshKhandeparkar I want your thoughts on it!
Needs a small rebase.