Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Text overlay now works in nodeJS #1518

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

rishabhshuklax
Copy link
Member

@rishabhshuklax rishabhshuklax commented Jan 17, 2020

Concerns #1378

Make sure these boxes are checked before your pull request (PR) is ready to be reviewed and merged. Thanks!

  • tests pass -- look for a green checkbox ✔️ a few minutes after opening your PR -- or run tests locally with npm test
  • code is in uniquely-named feature branch and has no merge conflicts
  • PR is descriptively titled
  • ask @publiclab/is-reviewers for help, in a comment below
  • 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
Copy link

codecov bot commented Jan 17, 2020

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% <ø> (ø) ⬆️
src/modules/DrawRectangle/DrawRectangle.js 100% <100%> (ø) ⬆️
src/modules/Gradient/Module.js 100% <100%> (ø) ⬆️

Copy link
Member

@harshkhandeparkar harshkhandeparkar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the info.json file for TextOverlay has a required field which needs to be removed. This field skips the test for this module.

@harshkhandeparkar
Copy link
Member

Waiting for the tests....

@harshkhandeparkar
Copy link
Member

Please fix the conflicts. Thanks!

@rishabhshuklax
Copy link
Member Author

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 😕 @ataata107 Why did you removed putImageData and used drawImage instead is there any major difference?

@harshkhandeparkar
Copy link
Member

Is it not working currently?

@rishabhshuklax
Copy link
Member Author

No, it isn't

@harshkhandeparkar
Copy link
Member

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

@rishabhshuklax
Copy link
Member Author

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

@harshkhandeparkar
Copy link
Member

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

@rishabhshuklax
Copy link
Member Author

rishabhshuklax commented Jan 20, 2020

Issue opened!
#1547

@ataata107
Copy link

@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

@rishabhshuklax
Copy link
Member Author

rishabhshuklax commented Jan 22, 2020

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


generateOutput was getting called beore the extramanipulation was completed so generateOutput was getting run twice!! one time in pixelManipulation and one time in extramanipulation
pixels = require('./TextOverlay')(pixels, options, dataUri, () => {
setRenderState(true);
generateOutput();

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! 😩

pixels = require('./TextOverlay')(pixels, options, dataUri, () => {
setRenderState(true);
generateOutput();

I'll open an issue regarding this and make a PR for it super soon!
@jywarren @harshkhandeparkar I want your thoughts on it!

@harshkhandeparkar
Copy link
Member

Needs a small rebase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants