image-sequencer icon indicating copy to clipboard operation
image-sequencer copied to clipboard

Text overlay now works in nodeJS

Open rishabhshuklax opened this issue 5 years ago • 13 comments

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-reviewers for 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!

rishabhshuklax avatar Jan 17 '20 14:01 rishabhshuklax

Codecov Report

Merging #1518 into main will increase coverage by 0.09%. The diff coverage is 100%.

Impacted file tree graph

@@            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:

codecov[bot] avatar Jan 17 '20 14:01 codecov[bot]

Waiting for the tests....

harshkhandeparkar avatar Jan 17 '20 17:01 harshkhandeparkar

Please fix the conflicts. Thanks!

harshkhandeparkar avatar Jan 19 '20 07:01 harshkhandeparkar

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?

rishabhshuklax avatar Jan 20 '20 12:01 rishabhshuklax

Is it not working currently?

harshkhandeparkar avatar Jan 20 '20 13:01 harshkhandeparkar

No, it isn't

rishabhshuklax avatar Jan 20 '20 15:01 rishabhshuklax

#1533 was a dangerous PR. We need to do a followup soon and fix some things.

harshkhandeparkar avatar Jan 20 '20 15:01 harshkhandeparkar

Yes! It also broke #1546, It was working fine before #1533, after that it is not resizing the image

rishabhshuklax avatar Jan 20 '20 15:01 rishabhshuklax

Hmm. Would you like to open an issue for this? Also mention some things which broke.

harshkhandeparkar avatar Jan 20 '20 15:01 harshkhandeparkar

Issue opened! #1547

rishabhshuklax avatar Jan 20 '20 15:01 rishabhshuklax

@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

ataata107 avatar Jan 21 '20 19:01 ataata107

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!

rishabhshuklax avatar Jan 22 '20 21:01 rishabhshuklax

Needs a small rebase.

harshkhandeparkar avatar Jul 08 '20 05:07 harshkhandeparkar