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

Node.js sample (dev) #22

Closed
wants to merge 34 commits into from
Closed

Node.js sample (dev) #22

wants to merge 34 commits into from

Conversation

ccpandhare
Copy link
Collaborator

Hey @jywarren, I made a small demo for the node.js implementation.
I'm not sure if it should be merged, but I wanted you to have a look at it.
To keep things clean, I have kept the Node.js version's code away from the working browser code. This is not how things will work out eventually, there will only be a single script. This is just for demonstration.

I am adding the suffix Node to all the new files generated in this PR. So there is an 'ImageSequencerNode.js', 'ModulesNode.js', etc. Also, I have added a demo module for Node, called DoNothingNode. It literally does nothing. just takes the input image and returns it as-is. This is all for testing purposes. So the only module which will currently work is DoNothingNode.

Also, this PR contains work from my other PR #17, the removeStep() one too.

First, get the additional dependancies installed (sharp and the likes)

$ npm install

Then run node terminal, requiring the index.js file beforehand.

$ node -r ./index

Now the node terminal opens, with index.js already required.

Type in the following in the node terminal to test ImageSequencer:

> sequencer
> sequencer.steps
> sequencer.addStep('do-nothing')
> sequencer.removeStep(0)
> sequencer.addStep('do-nothing')
> sequencer.steps
> sequencer.steps[0].get()

Note that the removeStep accepts the id parameter, one which I have defined in PR #17 . It is a unique auto-incrementing key which starts from 0.

@ccpandhare
Copy link
Collaborator Author

The build fails on Travis as TravisCI uses an older version of the dependancies required by Sharp.

@jywarren
Copy link
Member

jywarren commented Apr 3, 2017 via email

@ccpandhare
Copy link
Collaborator Author

I tried doing that... Turns out it doesn't help.
Any suggestions on how to overcome this?

@jywarren
Copy link
Member

jywarren commented Apr 4, 2017 via email

@ccpandhare
Copy link
Collaborator Author

Thanks a lot!

@ccpandhare
Copy link
Collaborator Author

@jywarren Could you have a look at this? Had University exams so couldn't have a look, sorry.

@jywarren
Copy link
Member

jywarren commented Apr 24, 2017 via email

@jywarren
Copy link
Member

Still trying to find a moment, my sincere apologies!

@ccpandhare
Copy link
Collaborator Author

Hey!
No issue at all :)

@jywarren
Copy link
Member

jywarren commented May 4, 2017

So, I think part of the problem may be that Sharp is not pure JavaScript, so I'm concerned that it bifurcates how things are run too much. I know that we can use the canvas for in-browser usage, but I do think we can bypass some of the problems with Sharp using Jimp. I know of other projects using Jimp too.

I appreciate the analysis done in this comment, but do you think attempting a Jimp based solution would address some of the issues and need for native compilation in this pull request?

@jywarren
Copy link
Member

jywarren commented May 4, 2017

Alternatively we could try to debug Sharp by searching for "Sharp in Travis" or looking closely at their documentation here: http://sharp.dimens.io/en/stable/install/

@ccpandhare
Copy link
Collaborator Author

Hey @jywarren
Was able to fix the issue.
Turns out all I had to do was set a minimum c++ compiler version in .travis.yml by doing this:

language: node_js
node_js:
  - '4'
  - '5'
env:
  - CXX=g++-4.8
script: npm test
addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - g++-4.8

@jywarren
Copy link
Member

Oh wow! Looking at the changes here now.

@@ -0,0 +1,67 @@
# Do not edit. File was generated by node-gyp's "configure" step
Copy link
Member

Choose a reason for hiding this comment

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

Is this an auto-generated file we should not be git tracking? Would you mind looking this up to see what the best practice is? Thanks!

@@ -0,0 +1,142 @@
ImageSequencer = function ImageSequencer(options) {
Copy link
Member

Choose a reason for hiding this comment

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

Hi, just checking - is this instead of another module, and how much redundancy is there? Or is this just a core module which is then included into another? I just want to be sure we don't replicate too much code if we could be using require() -- and it's been a few weeks :-P -- can you help me understand? Thank you!! Exciting to see work starting up!

return 'Addded.';
}

function removeStep (id) {
Copy link
Member

Choose a reason for hiding this comment

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

Yes, i'm concerned about redundancy -- isn't this the same code as this: https://github.com/publiclab/image-sequencer/pull/22/files#diff-f887b503b80e10727ac6cee436178fc5R83 ?

/*
* Demo Module. Does nothing.
*/
module.exports = function DoNothing(options) {
Copy link
Member

Choose a reason for hiding this comment

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

Hm, was this for testing purposes, or can we add a bit more to the description to explain why it's needed, so future programmers don't get confused? Thanks!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this was for testing purposes... This is a demo module which gives the output image as it is...

@ccpandhare
Copy link
Collaborator Author

I have shifted to a different branches and things have changed quite a lot. Also, as this was a demo, I wish to close this pull request. I am creating another pull request.

@ccpandhare ccpandhare closed this Jun 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants