mirror of
https://github.com/publiclab/image-sequencer.git
synced 2025-12-10 02:10:00 +01:00
Compare commits
50 Commits
v3.5.0
...
sashadev-s
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8f2f1e8b4 | ||
|
|
f1c94fd788 | ||
|
|
89626838e3 | ||
|
|
cff82c998f | ||
|
|
b1600af374 | ||
|
|
43e81c3847 | ||
|
|
44f5cb4e03 | ||
|
|
3eb741c6d9 | ||
|
|
33f32251ec | ||
|
|
5253e08d57 | ||
|
|
d782c147c5 | ||
|
|
339df8768d | ||
|
|
4a0207bc27 | ||
|
|
b7e97f315c | ||
|
|
9ad6bde18e | ||
|
|
740acaeec7 | ||
|
|
256e1d65c7 | ||
|
|
bab7573f4a | ||
|
|
776cb42bd6 | ||
|
|
fb452f7788 | ||
|
|
3741d679bd | ||
|
|
1cc9fd1a50 | ||
|
|
6613af810c | ||
|
|
1b3e95fdd9 | ||
|
|
560e027954 | ||
|
|
b43695cedb | ||
|
|
142c499119 | ||
|
|
03e9e42324 | ||
|
|
128e31492d | ||
|
|
c7980c1158 | ||
|
|
66e845d189 | ||
|
|
a95e57173b | ||
|
|
df3b16a1ed | ||
|
|
9fb87d7831 | ||
|
|
451a4ac3f2 | ||
|
|
5b98d5cf44 | ||
|
|
1b5607a339 | ||
|
|
5dca76c952 | ||
|
|
74ef42f485 | ||
|
|
e526fa47c6 | ||
|
|
68d5db7cff | ||
|
|
4dfdccada9 | ||
|
|
0db0943358 | ||
|
|
9464522017 | ||
|
|
1b26f71654 | ||
|
|
8033af9130 | ||
|
|
45aba96989 | ||
|
|
eff0d383c8 | ||
|
|
2c58edfe9a | ||
|
|
257113a948 |
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
4
.github/PULL_REQUEST_TEMPLATE.md
vendored
@@ -6,11 +6,11 @@ Make sure these boxes are checked before your pull request (PR) is ready to be r
|
||||
* [ ] 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!
|
||||
|
||||
@@ -1,114 +1,11 @@
|
||||
This document was copied from its home at https://publiclab.org/conduct on October 12, 2017. See that page if you would like to submit your concerns in a safe, completely anonymous way, and to learn more about this document.
|
||||
|
||||
****
|
||||
|
||||
# Public Lab Code of Conduct
|
||||
|
||||
_Public Lab, PO Box 426113, Cambridge, MA 02142_
|
||||
_Public Lab, 55 Cromwell Street, 1C, Providence, RI 02907_
|
||||
|
||||
We are coming together with an intent to care for ourselves and one another. We want to nurture a compassionate democratic culture where responsibility is shared. We -- visitors, community members, community moderators, staff, organizers, sponsors, and all others -- hold ourselves accountable to the same values regardless of position or experience. For this to work for everybody, individual decisions will not be allowed to run counter to the welfare of other people. This community aspires to be a respectful place both during online and in-person interactions so that all people are able to fully participate with their dignity intact. This document is a piece of the culture we're creating.
|
||||
We are coming together with an intent to care for ourselves and one another as we produce knowledge in pursuit of environmental justice. For this to work for everybody, individual decisions will not be allowed to run counter to the welfare of other people. We—visitors, community members, community moderators, staff, organizers, sponsors, and all others—hold ourselves accountable to the same values regardless of position or experience. This community aspires to be a respectful place both during online and in-person interactions so that all people are able to fully participate with their dignity intact. This document is a piece of the culture we're creating.
|
||||
|
||||
This code of conduct applies to all spaces managed by the Public Lab community and non-profit, both online and in person. It provides a clear set of practical guidelines for events led by organizers and community members, multi-day events such as Barnraisings, and online venues such as the website, comment threads on software platforms, chatrooms, our mailing lists, the issue tracker, and any other forums created by Public Lab which the community uses for communication. For interactions with additional groups, see our Partnership Guidelines at https://publiclab.org/partners.
|
||||
|
||||
This code of conduct applies to all spaces managed by the Public Lab community and non-profit, both online and in person. It was written by the Conduct Committee (formed in 2015 during Public Lab’s annual conference “The Barnraising”) and facilitated by staff to provide a clear set of practical guidelines for multi-day events such as Barnraisings, events led by organizers and community members, and online venues such as the website, comment threads on software platforms, chatrooms, our mailing lists, the issue tracker, and any other forums created by Public Lab which the community uses for communication.
|
||||
To read the full Code of Conduct and learn how to contact the Conduct Committee or the Moderators group, see:
|
||||
|
||||
|
||||
## We come from all kinds of backgrounds
|
||||
|
||||
Our community is best when we fully invite and include participants from a wide range of backgrounds. We specifically design spaces to be welcoming and accessible to newcomers and folks from underrepresented groups. Public Lab is dedicated to providing a harassment-free, safe, and inclusive experience for everyone, regardless of personal and professional background, gender, gender identity and expression, style of clothing, sexual orientation, dis-/ability, physical appearance, body size, race, class, age, or religion. Public Lab resists and rejects: racism, sexism, ableism, ageism, homophobia, transphobia, body shaming, religion shaming, “geekier-than-thou” shaming, education bias, the shaming of people nursing children, and the dismissal or bullying of children or adults.
|
||||
|
||||
## We do not tolerate harassment or shaming
|
||||
|
||||
While we operate under the assumption that all people involved with Public Lab subscribe to the basic understanding laid out above, we take these issues very seriously and think they should, in general, be taken seriously. Therefore, individuals who violate this Code both in and outside of Public Lab spaces may affect their ability to participate in Public Lab ranging from temporarily being placed into online moderation to, as a last resort, expulsion from the community. If you have any questions about our commitment to this framework and/or if you are unsure about aspects of it, email conduct@publiclab.org and we will do our best to provide clarification.
|
||||
|
||||
## How It Works
|
||||
|
||||
Sometimes things go wrong. When a situation is uncomfortable, hurtful, exclusionary, or upsetting, there is a problem that should be addressed. This code of conduct is an effort to maintain a safe space for everyone, and to talk about what might happen if that space is compromised. Please see additional guidelines below for community behavior on how we expect people to interact with one another.
|
||||
|
||||
### Two helpful groups
|
||||
|
||||
__Conduct Committee (ConductCom)__: If at any time you experience something that you are not comfortable with, you may contact the Conduct Committee. As established during the 2015 Annual Barnraising, the following individuals are on the Conduct Committee: Klie Kliebert, Carla Green, Nick Shapiro, and Shannon Dosemagen, the executive director of the Public Lab nonprofit.
|
||||
|
||||
|
||||
If you would like to have a confidential conversation, connect with ConductCom in person or email via [conduct@publiclab.org](mailto:conduct@publiclab.org). A minimum of two committee members will confer and respond as swiftly as possible. If you would prefer to speak privately with a representative of the nonprofit, please contact the executive director directly either in person or by email: [shannon@publiclab.org.](mailto:conduct@publiclab.org)
|
||||
|
||||
|
||||
To submit a report anonymously for review by ConductCom, go online via phone or computer to our anonymous “contact” app, located at [http://bit.ly/PLReport](http://bit.ly/PLReport). This contact app will be monitored daily at 8am CST during in-person events like Barnraisings and weekly at all other times. During multi-day in-person events hosted by the Public Lab non-profit, there will also be a physical suggestion box available. This box will be monitored throughout the event and can also be used to let us know if you need us to check on an anonymous online submission sooner.
|
||||
|
||||
|
||||
__Moderators Group:__ The moderators group is responsible for addressing immediate moderation issues that arise during online violations of the code over email lists and Public Lab community websites, as well as approving first-time posts and generally handling spam. Instructions on how to become a moderator, and, if you’ve been placed in moderation how to begin the process of getting out of moderation can be found at: https://publiclab.org/wiki/moderation.
|
||||
|
||||
****
|
||||
|
||||
## A Culture of Empathy
|
||||
|
||||
We begin interactions by acknowledging that we are part of a community with complementary goals. Different views are allowed to respectfully coexist in the same space. When something's happened and someone is uncomfortable, our first choice is to work through it. Endeavor to listen and appropriately adjust your behavior if someone approaches you privately with a request that you apologize or publicly requests that you stop an ongoing presentation. If someone questions your words, actions or motives, or "calls you out", hear their feedback and respond respectfully. It’s okay to not understand why something is hurtful or causes discomfort, as long as you approach it respectfully, with empathy. Repeating hurtful behavior after it has been addressed is disrespectful and is not allowed. Doing so will result in removal and subsequent banning from in-person events and being placed into moderation in online spaces.
|
||||
|
||||
### The first rule of engaging with others is consent
|
||||
|
||||
During in-person gatherings, consent is important to highlight because the negotiation of consent can be subtle, and it’s easy to miss each other’s non-verbal cues, resulting in miscommunication and/or offense. During online interactions, consent can be even harder to distinguish.
|
||||
|
||||
We make guesses or assessments of consent (willingness, welcome, invitation) all the time. Then we stay open to signs that the consent isn't there. Handshakes are a clear example of consent: someone offers a hand, and you take it if you want to shake it. A friendly smile might indicate consent to start a conversation. It might not. We learn that in the interaction. Sometimes we ask directly. We are open to making mistakes, and learning from them. The more we learn to be empathetic and see other people, the more we're able to talk about consent.
|
||||
|
||||
Before you engage with someone on any level, be sure you have their consent. If your indications aren't being heard, you can also ask for help from other folks, especially Conduct Committee members and staff of the non-profit: "They aren't taking the hint. Will you help?" Turning a blind eye to hurtful interactions can be as bad for our community as the exchange itself. If you witness something, it's your responsibility to say something. This is how we keep each other accountable, encourage empathy, and keep our community safe.
|
||||
|
||||
## Guidelines for in-person community behavior
|
||||
|
||||
|
||||
Do | Don’t
|
||||
----------- | -----------
|
||||
Respectfully share what method works best for you, while giving others space to think differently and contribute other ideas | Disparage entire groups/sets of people for their beliefs or methods
|
||||
Ask permission to take pictures of and post about others on social media (see Media Consent, above)| Upload photos, tag or mention others online without their consent
|
||||
Speak your own narrative, from your own unique culture | Caricature the cultural expressions of groups you are not a member of
|
||||
Model inclusionary expertise - if others in the group appear to be “lost”, slow down; stop and ask for input | Present information in a way / at a level that no one else in the room can understand, with no attempt to include others in the discussion
|
||||
Create events that are all-ages appropriate | Use language that excludes youth and their experiences as vital contributors
|
||||
Give everyone a chance to talk, only interrupting if absolutely necessary - for example, Code of Conduct violations | Repeatedly disrupt a discussion
|
||||
Stop, listen and ask for clarification if someone perceives your behavior or presentation as violating the Code of Conduct | Ignore others’ request to stop potentially harmful behavior, even if it was an accident
|
||||
Cultivate a sense of humor based on other subjects, such as word play (especially puns!) | Joke using words related to actual or insulting descriptions of people
|
||||
Use words that accurately describe the situation - For example, “The wind was ridiculously strong!” instead of “The wind was crazy!” | Use disability and mental/emotional health terminology to describe a situation metaphorically, especially if the phrasing is meant as an insult
|
||||
Only discuss someone else’s lifestyle practices if they invite you to a conversation on the topic | Make unwelcomed comments regarding a person’s lifestyle practices, including those related to food, health, parenting, relationships, and employment
|
||||
Ask someone before you hug them; keep your hands/body to yourself, even when joking, unless the other person has given verbal consent | Initiate physical contact or simulate physical contact without consent
|
||||
Disengage and find another activity if someone did not invite you and is not engaging with you | Violate personal space by continuing your physical presence into private spaces without consent
|
||||
Exercise the right to talk about your own identity if you want to, or not if you don’t want to | Deliberately “out” any aspect of a person’s identity without their consent
|
||||
Use the pronouns people have specified for themselves | Purposely misgender someone (ie, refusing to use their correct gender pronouns) after they have told you their correct pronouns
|
||||
|
||||
|
||||
## Additional guidelines for online community behavior
|
||||
|
||||
|
||||
Online modes of interaction involve large numbers of people without the helpful presence of gestural, expression, and tonal cues regarding consent. Because of this, respectful and self-aware online conduct is both especially important and difficult. Our community has evolved specific guidelines for online interactions.
|
||||
|
||||
_If someone violates these guidelines, someone from the Moderators group will place them into moderation by changing that person’s posting permission on the relevant list, on the website, or both._
|
||||
|
||||
Our triple notification standard for moderation means a point person from the Moderators group will:
|
||||
|
||||
1. e-mail the person directly with a brief explanation of what was violated,
|
||||
2. send a summary email to the rest of the moderators group,
|
||||
3. if it happened on a public list (vs a website), notify the list that one of our members has been placed into moderation with a brief explanation of what is not tolerated.
|
||||
|
||||
|
||||
If you wish to begin the process of getting out of moderation, respond to the email sent to you from [moderators@publiclab.org](mailto:moderators@publiclab.org). The Moderators group has the option to involve ConductCom.
|
||||
|
||||
|
||||
Do | Don’t
|
||||
-------|--------
|
||||
Stay on topic to make long threads easier to follow |Send spurious one-line responses that effectively "spam" hundreds of people and lower the overall content quality of a conversation. (Exception: expressions of appreciation and encouragement!)
|
||||
Start a new thread to help others follow along. Important if your response starts to significantly diverge from the original topic | Respond with off-topic information making it hard for the large group of readers to follow along
|
||||
Write short and literal subject lines to help the readers of the list manage the volume of communication | Humor and euphemisms in subject lines are easily misunderstood, although enthusiasm is welcome!
|
||||
Mind your tone. We are not having this conversation in person, so it is all the more important to maintain a tone of respect | Write in aggressive tone, disrespectful tone, mocking tone, off-color tone. Note: writing in all caps is regarded as shouting
|
||||
|
||||
## Media Consent
|
||||
|
||||
* ALWAYS check with parents about posting anything with minors.
|
||||
* Never post the names of minors in conjunction with their photo.
|
||||
* During multi-day events like Barnraisings most people will have signed media releases. Those who haven’t will be responsible for placing stickers on their nametags, and/or raising their hands in the moment to alert photographers to move them out of frame.
|
||||
* For events where people have not signed blanket media release forms, the photographer is responsible for letting the room know that you are taking photos that will be posted online. Pay special attention to the presence of minors and their parent's wishes.
|
||||
|
||||
|
||||
## Addendum for all staff
|
||||
|
||||
Staff are bound by their Employment Handbook, you must reference it. Additionally:
|
||||
|
||||
* Direct problems that come up among community members to the Conduct Committee.
|
||||
* When organizing events, circulate access information regarding wheelchair-accessible ADA bathrooms, non-gendered bathrooms, the presence of stairs or curb ramps in the parking lot, et cetera.
|
||||
* During events that you are attending in person, solve accessibility issues by making sure attendees know where bathrooms are located and can access them by wheelchair without being obstructed by things like chairs, kites, contraptions, or cords.
|
||||
* Watch for people feeling left out and include them.
|
||||
https://publiclab.org/conduct
|
||||
|
||||
@@ -5,7 +5,7 @@ Happily accepting pull requests; to edit the core library, modify files in `./sr
|
||||
|
||||
On ARM based devices, the `gl` module may require some libraries to be re-installed:
|
||||
|
||||
`sudo apt-get install -y build-essential libxi-dev libglu1-mesa-dev libglew-dev pkg-config` -- see https://github.com/stackgl/headless-gl#ubuntudebian for more.
|
||||
`sudo apt-get install -y build-essential xserver-xorg-dev libxext-dev libxi-dev libglu1-mesa-dev libglew-dev pkg-config` -- see https://github.com/stackgl/headless-gl#ubuntudebian for more.
|
||||
|
||||
Most contribution (we imagine) would be in the form of API-compatible modules, which need not be directly included.
|
||||
|
||||
@@ -425,8 +425,10 @@ var $step = scopeQuery.scopeSelector(scope),
|
||||
This will return an object with a constructor which returns a `jQuery` object (from inside the scope) but with new `elem` and `elemAll` methods.
|
||||
|
||||
#### Methods of the Returned Object
|
||||
* `elem()`: Selects an element inside the scope;
|
||||
* `elemAll()`: Selects all the instances of a given element inside the scope;
|
||||
* `elem()`: Selects an element inside the scope.
|
||||
* `elemAll()`: Selects all the instances of a given element inside the scope.
|
||||
* `getScope()`: Returns the scope as a DOM element.
|
||||
* `getDomElem()`: Returns the scoped element as a DOM element instead of a jquery object.
|
||||
|
||||
#### Example
|
||||
|
||||
|
||||
@@ -242,7 +242,7 @@ If only one module is to be added, `modules` is simply the name of the module.
|
||||
If multiple images are to be added, `modules` is an array, which holds the names of modules
|
||||
to be added, in that particular order.
|
||||
|
||||
optional_otions is just an optional parameter, in object form, which you might
|
||||
optional_options is just an optional parameter, in object form, which you might
|
||||
want to provide to the modules.
|
||||
|
||||
A variety of syntaxes are supported by Image Sequencer to add multiple steps and configurations quickly for module chaining. The project supports the string syntax, designed to be compact and URL friendly, and JSON, for handling more complex sequences. This can be achieved by passing strings to `sequencer.addStep()`:
|
||||
|
||||
640
docs/MODULES.md
640
docs/MODULES.md
@@ -3,48 +3,230 @@ Documentation of various Modules
|
||||
|
||||
List of Module Documentations
|
||||
|
||||
1. [Crop](#crop-module)
|
||||
2. [Segmented-Colormap](#segmented-colormap-module)
|
||||
3. [FisheyeGl](#fisheyeGl-module)
|
||||
4. [Add QR](#Add-QR-module)
|
||||
5. [Average](#average-module)
|
||||
6. [Blend](#blend-module)
|
||||
7. [Blur](#blur-module)
|
||||
8. [Brightness](#brightness-module)
|
||||
9. [Channel](#channel-module)
|
||||
10. [Colorbar](#colorbar-module)
|
||||
11. [Colormap](#colormap-module)
|
||||
12. [Contrast](#contrast-module)
|
||||
13. [Convolution](#convolution-module)
|
||||
14. [DecodeQr](#decodeQr-module)
|
||||
15. [Dither](#dither-module)
|
||||
16. [DrawRectangle](#draw-rectangle-module)
|
||||
17. [Dynamic](#dynamic-module)
|
||||
18. [Edge-Detect](#edge-detect-module)
|
||||
1. [Add QR](#Add-QR-module)
|
||||
2. [Average](#average-module)
|
||||
3. [Blend](#blend-module)
|
||||
4. [Blur](#blur-module)
|
||||
5. [Brightness](#brightness-module)
|
||||
6. [Channel](#channel-module)
|
||||
7. [Colorbar](#colorbar-module)
|
||||
8. [Colormap](#colormap-module)
|
||||
9. [ColorTemperature](#color-temperature)
|
||||
10. [Contrast](#contrast-module)
|
||||
11. [Convolution](#convolution-module)
|
||||
12. [Crop](#crop-module)
|
||||
13. [DecodeQr](#decodeQr-module)
|
||||
14. [Dither](#dither-module)
|
||||
15. [DrawRectangle](#draw-rectangle-module)
|
||||
16. [Dynamic](#dynamic-module)
|
||||
17. [Edge-Detect](#edge-detect-module)
|
||||
18. [FisheyeGl](#fisheyeGl-module)
|
||||
19. [FlipImage](#flipimage-module)
|
||||
20. [Gamma-Correction](#gamma-correction-module)
|
||||
21. [Gradient](#gradient-module)
|
||||
22. [Histogram](#histogram-module)
|
||||
23. [Import-image](#import-image-module)
|
||||
24. [Invert](#invert-module)
|
||||
25. [Ndvi](#ndvi-module)
|
||||
26. [Ndvi-Colormap](#ndvi-colormap-module)
|
||||
27. [Overlay](#overlay-module)
|
||||
28. [PaintBucket](#paint-bucket-module)
|
||||
29. [Resize](#resize-module)
|
||||
30. [ReplaceColor](#replacecolor-module)
|
||||
31. [Rotate](#rotate-module)
|
||||
32. [Saturation](#saturation-module)
|
||||
33. [Threshold](#threshold)
|
||||
34. [Tint](#tint)
|
||||
35. [ColorTemperature](#color-temperature)
|
||||
36. [Grid-Overlay](#grid-overlay)
|
||||
22. [Grid-Overlay](#grid-overlay)
|
||||
23. [Histogram](#histogram-module)
|
||||
24. [Import-image](#import-image-module)
|
||||
25. [Invert](#invert-module)
|
||||
26. [MinifyImage](#minify-image)
|
||||
27. [Ndvi](#ndvi-module)
|
||||
28. [Ndvi-Colormap](#ndvi-colormap-module)
|
||||
29. [NoiseReduction](#noise-reduction)
|
||||
30. [Overlay](#overlay-module)
|
||||
31. [PaintBucket](#paint-bucket-module)
|
||||
32. [ReplaceColor](#replacecolor-module)
|
||||
33. [Resize](#resize-module)
|
||||
34. [Rotate](#rotate-module)
|
||||
35. [Saturation](#saturation-module)
|
||||
36. [Segmented-Colormap](#segmented-colormap-module)
|
||||
37. [Text-Overlay](#text-overlay)
|
||||
38. [Threshold](#threshold)
|
||||
39. [Tint](#tint)
|
||||
|
||||
|
||||
## add-qr-module
|
||||
|
||||
This module Adds QR corresponding to the given string.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('add-qr',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following properties:
|
||||
* size : size of QR code in pixels (default 200)
|
||||
* qrCodeString : input string to generate QR code
|
||||
|
||||
|
||||
## average-module
|
||||
|
||||
This module is used for averaging all the pixels of the image.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('average',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
|
||||
## blend-module
|
||||
|
||||
This module is used for blending two images .
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('blend',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following properties:
|
||||
* offset: step of image with which current image is to be blended(Two steps back is -2, three steps back is -3 etc; default -2)
|
||||
* func: function used to blend two images (default : function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] })
|
||||
|
||||
## Blob Analysis
|
||||
|
||||
This module uses Opencv.js for detecting and marking blob/region in microscopic images. It requires an opencv.js file to
|
||||
be loaded before using the functionalities which is currently being loaded to the webpage via script.It supports both environments, Node.js and browser for processing.
|
||||
|
||||
As the size of opencv.js file is quite large, the future versions will focus on loading it asynchronously, on demand of the the module to optimise performance.
|
||||
|
||||
#### Usage
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('blob-analysis')
|
||||
.run()
|
||||
```
|
||||
|
||||
## blur-module
|
||||
|
||||
This module is used for applying a Gaussian blur effect.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('blur',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* blur : Intensity of Gaussian blur (0 to 5; default 2)
|
||||
|
||||
|
||||
## brightness-module
|
||||
|
||||
This module is used for changing the brightness of the image.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('brightness',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* brightness : brightness of the image in percentage (0 to 100; default 100)
|
||||
|
||||
|
||||
## channel-module
|
||||
|
||||
This module is used for forming a grayscale image by applying one of the three primary colors.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('channel',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* channel : color of the channel (red, green, blue; default green)
|
||||
|
||||
|
||||
## colorbar-module
|
||||
|
||||
This module is used for displaying an image with a colorbar.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('colorbar',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following properties:
|
||||
* colormap : Name of the Colormap(default, greyscale, stretched, fastie, brntogrn, blutoredjet, colors16; default: default)
|
||||
* x : X-position of the image on which the new image is overlayed (default 0)
|
||||
* y : Y-position of the image on which the new image is overlayed (default 0)
|
||||
* h : height of resulting cropped image (default : 50% of input image width )
|
||||
|
||||
|
||||
## colormap-module
|
||||
|
||||
This module is used for mapping brightness values (average of red, green & blue) to a given color lookup table, made up of a set of one more color gradients.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('colormap',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* colormap : Name of the Colormap ( greyscale, stretched, fastie, brntogrn, blutoredjet, colors16)
|
||||
|
||||
|
||||
## Color Temperature
|
||||
|
||||
This changes the color temperature of the image.
|
||||
## Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('color-temperature',options)
|
||||
.run()
|
||||
```
|
||||
where `options` is an object with the following property:
|
||||
* temperature : temperature between 0 - 40,000 kelvin (default 6000)
|
||||
|
||||
|
||||
## contrast-module
|
||||
|
||||
This module is used for changing the contrast of the image.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('contrast',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* contrast : contrast for the given image (-100 to 100; default : 70)
|
||||
|
||||
|
||||
## convolution-module
|
||||
|
||||
This module is used for performing image-convolution.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('convolution',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following properties:
|
||||
* constantFactor : a constant factor, multiplies all the kernel values by that factor (default : 1/9)
|
||||
* kernelValues : nine space separated numbers representing the kernel values in left to right and top to bottom format(default : 1 1 1 1 1 1 1 1 1)
|
||||
|
||||
|
||||
## crop-module
|
||||
|
||||
This module is used to crop an image.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
@@ -64,208 +246,9 @@ Where `options` is an object having the properties `x`, `y`, `w`, `h`. This diag
|
||||
* `options.h` : half of image height
|
||||
|
||||
|
||||
## segmented-colormap-module
|
||||
|
||||
This module is used to map the pixels of the image to a segmented colormap.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('segmented-colormap',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the property `colormap`. `options.colormap` can be:
|
||||
|
||||
* "default" : [[0, [0, 0, 255], [38, 195, 195]], [0.5, [0, 150, 0], [255, 255, 0]], [0.75, [255, 255, 0], [255, 50, 50]]]
|
||||
|
||||
* "greyscale" : [[0, [0, 0, 0], [255, 255, 255]], [1, [255, 255, 255], [255, 255, 255]]]
|
||||
|
||||
* "stretched" : [[0, [0, 0, 255], [0, 0, 255]], [0.1, [0, 0, 255], [38, 195, 195]], [0.5, [0, 150, 0], [255, 255, 0]], [0.7, [255, 255, 0], [255, 50, 50]], [0.9, [255, 50, 50], [255, 50, 50]]]
|
||||
|
||||
* "fastie" : [[0, [255, 255, 255], [0, 0, 0]], [0.167, [0, 0, 0], [255, 255, 255]], [0.33, [255, 255, 255], [0, 0, 0]], [0.5, [0, 0, 0], [140, 140, 255]], [0.55, [140, 140, 255], [0, 255, 0]], [0.63, [0, 255, 0], [255, 255, 0]], [0.75, [255, 255, 0], [255, 0, 0]], [0.95, [255, 0, 0], [255, 0, 255]]]
|
||||
|
||||
* A custom array.
|
||||
|
||||
## fisheyeGl-module
|
||||
|
||||
This module is used for correcting Fisheye or Lens Distortion
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('fisheye-gl',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following properties:
|
||||
* a : a correction (0 to 4; default 1)
|
||||
* b : b correction (0 to 4; default 1)
|
||||
* Fx : x correction (0 to 4; default 1)
|
||||
* Fy : y correction (0 to 4; default 1)
|
||||
* scale : The ratio to which the original image is to be scaled (0 to 20; default 1.5)
|
||||
* x : Field of View x (0 to 2; default 1)
|
||||
* y : Field of View y (0 to 2; default 1)
|
||||
|
||||
## add-qr-module
|
||||
|
||||
This module Adds QR corresponding to the given string.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('add-qr',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following properties:
|
||||
* size : size of QR code in pixels (default 200)
|
||||
* qrCodeString : input string to generate QR code
|
||||
|
||||
|
||||
## average-module
|
||||
|
||||
This module is used for averaging all the pixels of the image.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('average',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
## blend-module
|
||||
|
||||
This module is used for blending two images .
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('blend',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following properties:
|
||||
* offset: step of image with which current image is to be blended(Two steps back is -2, three steps back is -3 etc; default -2)
|
||||
* func: function used to blend two images (default : function(r1, g1, b1, a1, r2, g2, b2, a2) { return [ r1, g2, b2, a2 ] })
|
||||
|
||||
## blur-module
|
||||
|
||||
This module is used for applying a Gaussian blur effect.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('blur',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* blur : Intensity of Gaussian blur (0 to 5; default 2)
|
||||
|
||||
## brightness-module
|
||||
|
||||
This module is used for changing the brightness of the image.
|
||||
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('brightness',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* brightness : brightness of the image in percentage (0 to 100; default 100)
|
||||
|
||||
## channel-module
|
||||
|
||||
This module is used for forming a grayscale image by applying one of the three primary colors.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('channel',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* channel : color of the channel (red, green, blue; default green)
|
||||
|
||||
## colorbar-module
|
||||
|
||||
This module is used for displaying an image with a colorbar.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('colorbar',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following properties:
|
||||
* colormap : Name of the Colormap(default, greyscale, stretched, fastie, brntogrn, blutoredjet, colors16; default: default)
|
||||
* x : X-position of the image on which the new image is overlayed (default 0)
|
||||
* y : Y-position of the image on which the new image is overlayed (default 0)
|
||||
* h : height of resulting cropped image (default : 50% of input image width )
|
||||
|
||||
## colormap-module
|
||||
|
||||
This module is used for mapping brightness values (average of red, green & blue) to a given color lookup table, made up of a set of one more color gradients.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('colormap',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* colormap : Name of the Colormap ( greyscale, stretched, fastie, brntogrn, blutoredjet, colors16)
|
||||
|
||||
## contrast-module
|
||||
|
||||
This module is used for changing the contrast of the image.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('contrast',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* contrast : contrast for the given image (-100 to 100; default : 70)
|
||||
|
||||
## convolution-module
|
||||
|
||||
This module is used for performing image-convolution.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('convolution',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following properties:
|
||||
* constantFactor : a constant factor, multiplies all the kernel values by that factor (default : 1/9)
|
||||
* kernelValues : nine space separated numbers representing the kernel values in left to right and top to bottom format(default : 1 1 1 1 1 1 1 1 1)
|
||||
|
||||
## decodeQr-module
|
||||
|
||||
This module is used for decoding a QR in image (if present).
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
@@ -279,8 +262,7 @@ This module is used for decoding a QR in image (if present).
|
||||
This module approximates a color from a mixture of other colors when the required color is not available, creating illusions of the color that is not present actually.
|
||||
|
||||
[more info on wikipedia](https://en.wikipedia.org/wiki/Dither)
|
||||
|
||||
## Usage
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
@@ -290,10 +272,10 @@ This module approximates a color from a mixture of other colors when the require
|
||||
where `options` is an object with the following property:
|
||||
* dither : Can select the name of the Dithering Algorithm(default none)
|
||||
|
||||
|
||||
## draw-rectangle-module
|
||||
|
||||
This module helps to draw a rectangle on the image with a starting and ending corner with the specified thickness and color of the border.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
@@ -309,10 +291,10 @@ where `options` is an object with the following properties:
|
||||
* thickness : thickness of the border (default 1)
|
||||
* color : RGBA values separated by a space (default "0 0 0 255")
|
||||
|
||||
|
||||
## dynamic-module
|
||||
|
||||
This module is used for producing each color channel based on the original image's color.
|
||||
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
@@ -327,6 +309,7 @@ where `options` is an object with the following properties:
|
||||
* blue : expression for blue channel (R, G, B and A as inputs; default b)
|
||||
* monochrome: fallback for other channels if none provided (default : r+g+b/3)
|
||||
|
||||
|
||||
## edge-detect-module
|
||||
|
||||
This module is used for detecting images.
|
||||
@@ -343,12 +326,33 @@ where `options` is an object with the following properties:
|
||||
* highThresholdRatio : Upper Threshold Ratio ( default : 0.2)
|
||||
* lowThresholdratio : Lower Threshold Ratio ( default : 0.2)
|
||||
|
||||
|
||||
## fisheyeGl-module
|
||||
|
||||
This module is used for correcting Fisheye or Lens Distortion
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('fisheye-gl',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following properties:
|
||||
* a : a correction (0 to 4; default 1)
|
||||
* b : b correction (0 to 4; default 1)
|
||||
* Fx : x correction (0 to 4; default 1)
|
||||
* Fy : y correction (0 to 4; default 1)
|
||||
* scale : The ratio to which the original image is to be scaled (0 to 20; default 1.5)
|
||||
* x : Field of View x (0 to 2; default 1)
|
||||
* y : Field of View y (0 to 2; default 1)
|
||||
|
||||
|
||||
## flipimage-module
|
||||
|
||||
This module is used for flipping the image on the selected axis.
|
||||
#### Usage
|
||||
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('flip-image',options)
|
||||
@@ -373,6 +377,7 @@ This module is used for applying gamma correction.
|
||||
where `options` is an object with the following property:
|
||||
* adjustment : Inverse of actual gamma factor (default 0.2)
|
||||
|
||||
|
||||
## gradient-module
|
||||
|
||||
This module is used for finding gradient of the image.
|
||||
@@ -384,6 +389,23 @@ This module is used for finding gradient of the image.
|
||||
.run()
|
||||
```
|
||||
|
||||
|
||||
## Grid Overlay
|
||||
|
||||
This adds the grid over an image.
|
||||
## Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('grid-overlay',options)
|
||||
.run()
|
||||
```
|
||||
where `options` is an object with the following property:
|
||||
* options.x : The value at which the grid line should start in x-axis.
|
||||
* options.y : The value at which the grid line should start in y-axis.
|
||||
* color : Color for the grid on the image.
|
||||
|
||||
|
||||
## histogram-module
|
||||
|
||||
This module is used for calculating histogram of the image.
|
||||
@@ -398,6 +420,7 @@ This module is used for calculating histogram of the image.
|
||||
where `options` is an object with the following property:
|
||||
* gradient : boolean value used to toggle gradient along x-axis (true or false; default true)
|
||||
|
||||
|
||||
## import-image-module
|
||||
|
||||
This module is used for importing a new image and replacing the original with it.
|
||||
@@ -412,6 +435,7 @@ This module is used for importing a new image and replacing the original with it
|
||||
where `options` is an object with the following property:
|
||||
* url : url of the new image (local image url or data url;default : "./images/monarch.png")
|
||||
|
||||
|
||||
## invert-module
|
||||
|
||||
This module is used for inverting the image.
|
||||
@@ -423,6 +447,21 @@ This module is used for inverting the image.
|
||||
.run()
|
||||
```
|
||||
|
||||
|
||||
## Minify Image
|
||||
|
||||
This module minifies the image using lossy compression that is the image-dimensions are not lost but the size is reduced.
|
||||
|
||||
The module supports jpg/jpeg/webp images in browser; but the node version supports all of the types.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('minify-image')
|
||||
.run()
|
||||
```
|
||||
|
||||
|
||||
## ndvi-module
|
||||
|
||||
This module is used for applying ndvi technique to the image.
|
||||
@@ -437,6 +476,7 @@ This module is used for applying ndvi technique to the image.
|
||||
where `options` is an object with the following property:
|
||||
* filter : filter for NDVI (blue or red; default red)
|
||||
|
||||
|
||||
## ndvi-colormap-module
|
||||
|
||||
This module is used for demonstrating ndvi and colormap properties consecutively.
|
||||
@@ -448,6 +488,22 @@ This module is used for demonstrating ndvi and colormap properties consecutively
|
||||
.run()
|
||||
```
|
||||
|
||||
|
||||
## Noise-Reduction
|
||||
|
||||
Noise in an image are atypical pixels that are not representing the color or the exposure of the scene correctly. This Noise Reduction module reduces the noise in the image by using either median filtering or mean filtering techniques to change the RGB value of the pixels to create a smoother and fuller image.
|
||||
|
||||
#### Usage
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('noise-reduction',options)
|
||||
.run()
|
||||
```
|
||||
where `options` is an object with the property `method`. `options.method` can be:
|
||||
* Median Filtering: Set the RGB value of the pixel to the median RGB pixel value of all adjacent pixels (maximum 8 adjacent pixels and itself)
|
||||
* Mean Filtering: Set the RGB value of the pixel to the mean RGB pixel value of all adjacent pixels (maximum 8 adjacent pixels and itself)
|
||||
|
||||
|
||||
## overlay-module
|
||||
|
||||
This module is used for overlaying an Image over another .
|
||||
@@ -464,10 +520,10 @@ where `options` is an object with the following properties:
|
||||
* y : Y-position of the image on which the new image is overlayed (default 0)
|
||||
* offset : offset to the step on which the output of the last step is overlayed (default -2)
|
||||
|
||||
|
||||
## paint-bucket-module
|
||||
|
||||
This module fills any polygonal shape with the specified color in pixels.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
@@ -482,19 +538,6 @@ where `options` is an object with the following property:
|
||||
* fillColor : they are four spaced seperated numbers representing the RGBA values of fill-color (default "100 100 100 255")
|
||||
* tolerance : it is the % tolerance (default 10)
|
||||
|
||||
## resize-module
|
||||
|
||||
This module is used for resizing an image.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('resize',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* resize : Percentage value of resize (default 125%)
|
||||
|
||||
## replacecolor-module
|
||||
|
||||
@@ -512,6 +555,22 @@ where `options` is an object with the following properties:
|
||||
* color : three space separated numbers representing the RGB values of color to be replaced (default "228 86 81")
|
||||
* tolerance : it is the % tolerance (default 50)
|
||||
|
||||
|
||||
## resize-module
|
||||
|
||||
This module is used for resizing an image.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('resize',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the following property:
|
||||
* resize : Percentage value of resize (default 125%)
|
||||
|
||||
|
||||
## rotate-module
|
||||
|
||||
This module is used for rotating an image.
|
||||
@@ -526,6 +585,7 @@ This module is used for rotating an image.
|
||||
where `options` is an object with the following property:
|
||||
* rotate : angular value for rotation in degrees (between 0 and 360; default 0)
|
||||
|
||||
|
||||
## saturation-module
|
||||
|
||||
This module is used for changing the saturation of the image.
|
||||
@@ -540,11 +600,49 @@ This module is used for changing the saturation of the image.
|
||||
where `options` is an object with the following property:
|
||||
* saturation : saturation for the new image (between 0 and 2; default 0)
|
||||
|
||||
|
||||
## segmented-colormap-module
|
||||
|
||||
This module is used to map the pixels of the image to a segmented colormap.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('segmented-colormap',options)
|
||||
.run()
|
||||
```
|
||||
|
||||
where `options` is an object with the property `colormap`. `options.colormap` can be:
|
||||
|
||||
* "default" : [[0, [0, 0, 255], [38, 195, 195]], [0.5, [0, 150, 0], [255, 255, 0]], [0.75, [255, 255, 0], [255, 50, 50]]]
|
||||
|
||||
* "greyscale" : [[0, [0, 0, 0], [255, 255, 255]], [1, [255, 255, 255], [255, 255, 255]]]
|
||||
|
||||
* "stretched" : [[0, [0, 0, 255], [0, 0, 255]], [0.1, [0, 0, 255], [38, 195, 195]], [0.5, [0, 150, 0], [255, 255, 0]], [0.7, [255, 255, 0], [255, 50, 50]], [0.9, [255, 50, 50], [255, 50, 50]]]
|
||||
|
||||
* "fastie" : [[0, [255, 255, 255], [0, 0, 0]], [0.167, [0, 0, 0], [255, 255, 255]], [0.33, [255, 255, 255], [0, 0, 0]], [0.5, [0, 0, 0], [140, 140, 255]], [0.55, [140, 140, 255], [0, 255, 0]], [0.63, [0, 255, 0], [255, 255, 0]], [0.75, [255, 255, 0], [255, 0, 0]], [0.95, [255, 0, 0], [255, 0, 255]]]
|
||||
|
||||
* A custom array.
|
||||
|
||||
|
||||
## Text Overlay
|
||||
|
||||
The modules allows to add text to image in both browser and node environment. We have the options to modify the font-size and also support few font-styles. The text color can also be modified.
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('grid-overlay',options)
|
||||
.run()
|
||||
```
|
||||
The options can take various attributes like,
|
||||
var options = { text : 'Hello World', size : '12'};
|
||||
|
||||
|
||||
## Threshold
|
||||
|
||||
Thresholding is used to create binary images.
|
||||
|
||||
## Usage
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
@@ -559,8 +657,7 @@ where `options` is an object with the following property:
|
||||
## Tint
|
||||
|
||||
It adds color tint to an image
|
||||
|
||||
## Usage
|
||||
#### Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
@@ -570,34 +667,3 @@ It adds color tint to an image
|
||||
where `options` is an object with the following property:
|
||||
* color : RGB values seperated by a space (default "0 0 255")
|
||||
* factor : amount of tint (default 0.5)
|
||||
|
||||
|
||||
## Color Temperature
|
||||
|
||||
This changes the color temperature of the image.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('color-temperature',options)
|
||||
.run()
|
||||
```
|
||||
where `options` is an object with the following property:
|
||||
* temperature : temperature between 0 - 40,000 kelvin (default 6000)
|
||||
|
||||
## Grid Overlay
|
||||
|
||||
This adds the grid over an image.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
sequencer.loadImage('PATH')
|
||||
.addSteps('grid-overlay',options)
|
||||
.run()
|
||||
```
|
||||
where `options` is an object with the following property:
|
||||
* options.x : The value at which the grid line should start in x-axis.
|
||||
* options.y : The value at which the grid line should start in y-axis.
|
||||
* color : Color for the grid on the image.
|
||||
@@ -44,6 +44,11 @@ body > .container-fluid {
|
||||
.panel {
|
||||
margin-left: 20px;
|
||||
margin-right: 20px;
|
||||
min-width:400px;
|
||||
}
|
||||
|
||||
.mouse {
|
||||
cursor: pointer !important;
|
||||
}
|
||||
|
||||
.nomargin {
|
||||
@@ -61,6 +66,7 @@ body > .container-fluid {
|
||||
border-radius: 8px;
|
||||
text-align: center;
|
||||
color: #444;
|
||||
min-width:300px;
|
||||
}
|
||||
|
||||
.hover {
|
||||
@@ -103,7 +109,10 @@ body > .container-fluid {
|
||||
}
|
||||
|
||||
#add-step-btn{
|
||||
margin-left: 10px;
|
||||
width: 100%
|
||||
}
|
||||
.selectize-input {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
#addStep .labels {
|
||||
@@ -140,7 +149,6 @@ body > .container-fluid {
|
||||
#dwnld {
|
||||
max-width: 500px;
|
||||
margin: 20px auto;
|
||||
margin-left: 5px;
|
||||
}
|
||||
|
||||
#gif_element {
|
||||
@@ -250,7 +258,8 @@ a.name-header{
|
||||
}
|
||||
|
||||
.trash-container button.btn-xs {
|
||||
margin-top: -5px !important;
|
||||
position: relative;
|
||||
bottom: 7px;
|
||||
}
|
||||
|
||||
.toggleIcon {
|
||||
@@ -276,3 +285,22 @@ a.name-header{
|
||||
.toggle {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.dimension-tooltip:hover{
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.dimension-tooltip:focus{
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.dimension-tooltip:focus-within{
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.dimension-tooltip{
|
||||
position: relative;
|
||||
bottom: 7px;
|
||||
font-size: 16px;
|
||||
color: #444;
|
||||
}
|
||||
104
examples/demo.js
104
examples/demo.js
@@ -5,7 +5,7 @@ var defaultHtmlSequencerUi = require('./lib/defaultHtmlSequencerUi.js'),
|
||||
urlHash = require('./lib/urlHash.js'),
|
||||
insertPreview = require('./lib/insertPreview.js');
|
||||
|
||||
window.onload = function() {
|
||||
window.onload = function () {
|
||||
sequencer = ImageSequencer();
|
||||
|
||||
function refreshOptions() {
|
||||
@@ -62,7 +62,7 @@ window.onload = function() {
|
||||
sequencer.loadImage('images/tulips.png', ui.onLoad);
|
||||
}
|
||||
|
||||
var resetSequence = function(){
|
||||
var resetSequence = function () {
|
||||
var r = confirm('Do you want to reset the sequence?');
|
||||
if (r)
|
||||
window.location = '/';
|
||||
@@ -73,7 +73,7 @@ window.onload = function() {
|
||||
$('#resetButton').on('click', resetSequence);
|
||||
|
||||
//Module button radio selection
|
||||
$('.radio-group .radio').on('click', function() {
|
||||
$('.radio-group .radio').on('click', function () {
|
||||
$(this).parent().find('.radio').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
newStep = $(this).attr('data-value');
|
||||
@@ -84,29 +84,44 @@ window.onload = function() {
|
||||
$(this).removeClass('selected');
|
||||
});
|
||||
|
||||
function displayMessageOnSaveSequence(){
|
||||
function displayMessageOnSaveSequence() {
|
||||
$('.savesequencemsg').fadeIn();
|
||||
setTimeout(function() {
|
||||
setTimeout(function () {
|
||||
$('.savesequencemsg').fadeOut();
|
||||
}, 1000);
|
||||
}, 3000);
|
||||
}
|
||||
|
||||
$('body').on('click', 'button.remove', ui.removeStepUi);
|
||||
$('#save-seq').click(() => {
|
||||
function saveSequence() { // 1. save seq
|
||||
var result = window.prompt('Please give a name to your sequence... (Saved sequence will only be available in this browser).');
|
||||
if(result){
|
||||
if (result) {
|
||||
result = result + ' (local)';
|
||||
sequencer.saveSequence(result, sequencer.toString());
|
||||
sequencer.saveSequence(result, sequencer.toString()); // 1.a study saveSequence
|
||||
sequencer.loadModules();
|
||||
displayMessageOnSaveSequence();
|
||||
refreshOptions();
|
||||
}
|
||||
}
|
||||
$('#saveButton').on('click', function () {
|
||||
// different handlers triggered for different dropdown options
|
||||
|
||||
let dropDownValue = $('#selectSaveOption option:selected').val();
|
||||
|
||||
if (dropDownValue == 'save-image') {
|
||||
$('.download-btn:last()').trigger('click');
|
||||
}
|
||||
else if (dropDownValue == 'save-gif') {
|
||||
handleSavePNG();
|
||||
}
|
||||
else if (dropDownValue == 'save-seq') {
|
||||
saveSequence();
|
||||
}
|
||||
});
|
||||
|
||||
var isWorkingOnGifGeneration = false;
|
||||
let isWorkingOnGifGeneration = false;
|
||||
|
||||
$('.js-view-as-gif').on('click', function(event) {
|
||||
// Prevent user from triggering generation multiple times
|
||||
$('.js-view-as-gif').on('click', function (event) {
|
||||
/* Prevent user from triggering generation multiple times*/
|
||||
if (isWorkingOnGifGeneration) return;
|
||||
|
||||
isWorkingOnGifGeneration = true;
|
||||
@@ -116,23 +131,10 @@ window.onload = function() {
|
||||
button.innerHTML = '<i class="fa fa-circle-o-notch fa-spin"></i>';
|
||||
|
||||
try {
|
||||
// Select all images from previous steps
|
||||
var imgs = document.getElementsByClassName('step-thumbnail');
|
||||
/* Get gif resources of previous steps */
|
||||
let options = getGifResources();
|
||||
|
||||
var imgSrcs = [];
|
||||
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
imgSrcs.push(imgs[i].src);
|
||||
}
|
||||
|
||||
var options = {
|
||||
'gifWidth': imgs[0].width,
|
||||
'gifHeight': imgs[0].height,
|
||||
'images': imgSrcs,
|
||||
'frameDuration': 7,
|
||||
};
|
||||
|
||||
gifshot.createGIF(options, function(obj) {
|
||||
gifshot.createGIF(options, function (obj) { // gif generation
|
||||
if (!obj.error) {
|
||||
// Final gif encoded with base64 format
|
||||
var image = obj.image;
|
||||
@@ -141,13 +143,11 @@ window.onload = function() {
|
||||
animatedImage.id = 'gif_element';
|
||||
animatedImage.src = image;
|
||||
|
||||
let modal = $('#js-download-gif-modal');
|
||||
|
||||
var modal = $('#js-download-gif-modal');
|
||||
|
||||
$('#js-download-as-gif-button').one('click', function() {
|
||||
$('#js-download-as-gif-button').one('click', function () {
|
||||
// Trigger download
|
||||
download(image, 'index.gif', 'image/gif');
|
||||
|
||||
downloadGif(image);
|
||||
// Close modal
|
||||
modal.modal('hide');
|
||||
});
|
||||
@@ -175,10 +175,42 @@ window.onload = function() {
|
||||
button.disabled = false;
|
||||
button.innerHTML = 'View GIF';
|
||||
isWorkingOnGifGeneration = false;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
function getGifResources() {
|
||||
/* Returns an object with specific gif options */
|
||||
let imgs = document.getElementsByClassName('step-thumbnail');
|
||||
var imgSrcs = [];
|
||||
|
||||
// Pushes image sources of all the modules in dom
|
||||
for (var i = 0; i < imgs.length; i++) {
|
||||
imgSrcs.push(imgs[i].src);
|
||||
}
|
||||
|
||||
var options = { // gif frame options
|
||||
'gifWidth': imgs[0].width,
|
||||
'gifHeight': imgs[0].height,
|
||||
'images': imgSrcs,
|
||||
'frameDuration': 7,
|
||||
};
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
function handleSavePNG() {
|
||||
let options = getGifResources();
|
||||
gifshot.createGIF(options, function(obj){
|
||||
|
||||
downloadGif(obj.image);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function downloadGif(image) {
|
||||
download(image, 'index.gif', 'image/gif');// downloadjs library function
|
||||
}
|
||||
|
||||
// image selection and drag/drop handling from examples/lib/imageSelection.js
|
||||
sequencer.setInputStep({
|
||||
dropZoneSelector: '#dropzone',
|
||||
@@ -190,7 +222,7 @@ window.onload = function() {
|
||||
var util = intermediateHtmlStepUi(sequencer);
|
||||
step.output.src = reader.result;
|
||||
sequencer.run({ index: 0 });
|
||||
if(typeof step.options !== 'undefined')
|
||||
if (typeof step.options !== 'undefined')
|
||||
step.options.step.imgElement.src = reader.result;
|
||||
else
|
||||
step.imgElement.src = reader.result;
|
||||
@@ -201,7 +233,7 @@ window.onload = function() {
|
||||
var step = sequencer.steps[0];
|
||||
step.output.src = url;
|
||||
sequencer.run({ index: 0 });
|
||||
if(typeof step.options !== 'undefined')
|
||||
if (typeof step.options !== 'undefined')
|
||||
step.options.step.imgElement.src = url;
|
||||
else
|
||||
step.imgElement.src = url;
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
|
||||
<div class="container-fluid">
|
||||
|
||||
<header class="text-center">
|
||||
<header class="text-center" style="min-width: 450px">
|
||||
<h1><a href="/" target='_blank' class="name-header">Image Sequencer</a></h1>
|
||||
<p>
|
||||
A pure JavaScript sequential image processing system, inspired by storyboards. Instead of modifying the original
|
||||
@@ -91,7 +91,7 @@
|
||||
</section>
|
||||
|
||||
<hr />
|
||||
<p class="alert alert-success savesequencemsg">Saved Sequence Success. Sequence can be found among other modules.
|
||||
<p class="alert alert-success savesequencemsg">Saved Sequence Success. Sequence can be found among other modules in browser's localStorage.
|
||||
</p>
|
||||
<div class="row">
|
||||
<div class="col-sm-8">
|
||||
@@ -139,15 +139,15 @@
|
||||
<p>Crop</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row center-align">
|
||||
<div class="col-md-8">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-8">
|
||||
|
||||
<select id="selectStep">
|
||||
<select id="selectStep" class="text-center">
|
||||
<!-- The default null selection has been appended manually in demo.js
|
||||
This is because the options in select are overritten when options are appended.-->
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div class="col-lg-4">
|
||||
<button class="btn btn-success btn-lg" name="add" id="add-step-btn">Add Step</button></div>
|
||||
</div>
|
||||
<div class="row center-align">
|
||||
@@ -187,11 +187,11 @@
|
||||
<div class="panel-body">
|
||||
<div style="text-align:center;">
|
||||
<h2 style="margin-top:20px">Save</h2>
|
||||
<select class="form-control input-md" id="selectSaveOption" style="margin-top:20px">
|
||||
<option>Save as PNG</option>
|
||||
<option>Save as GIF (all steps)</option>
|
||||
<option>Save sequence</option>
|
||||
<option>Save sequence string</option>
|
||||
<select class="form-control input-md mouse" id="selectSaveOption" style="margin-top:20px">
|
||||
<option value="save-image">Save as PNG</option>
|
||||
<option value="save-gif">Save as GIF (all steps)</option>
|
||||
<option value="save-seq">Save sequence</option>
|
||||
<option value="save-seq-string">Save sequence string</option>
|
||||
</select>
|
||||
<p><button id="saveButton" class="btn btn-primary btn-lg save-button">Save</button></p>
|
||||
<p><button class="btn btn-default btn-lg js-view-as-gif" id="gif">Preview GIF</button></p>
|
||||
@@ -232,6 +232,7 @@
|
||||
var sequencer;
|
||||
})
|
||||
</script>
|
||||
<script async src="../node_modules/opencv.js/opencv.js" type="text/javascript"></script>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
@@ -8,18 +8,21 @@
|
||||
// output values, step information.
|
||||
// See documetation for more details.
|
||||
|
||||
var intermediateHtmlStepUi = require('./intermediateHtmlStepUi.js');
|
||||
var urlHash = require('./urlHash.js');
|
||||
var _ = require('lodash');
|
||||
var mapHtmlTypes = require('./mapHtmltypes');
|
||||
const intermediateHtmlStepUi = require('./intermediateHtmlStepUi.js'),
|
||||
urlHash = require('./urlHash.js'),
|
||||
_ = require('lodash'),
|
||||
mapHtmlTypes = require('./mapHtmltypes'),
|
||||
scopeQuery = require('./scopeQuery');
|
||||
|
||||
function DefaultHtmlStepUi(_sequencer, options) {
|
||||
|
||||
let $step, $stepAll;
|
||||
|
||||
options = options || {};
|
||||
var stepsEl = options.stepsEl || document.querySelector('#steps');
|
||||
var selectStepSel = options.selectStepSel = options.selectStepSel || '#selectStep';
|
||||
|
||||
function onSetup(step, stepOptions) {
|
||||
|
||||
if (step.options && step.options.description)
|
||||
step.description = step.options.description;
|
||||
|
||||
@@ -28,9 +31,9 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
<div class="container-fluid step-container">\
|
||||
<div class="panel panel-default">\
|
||||
<div class="panel-heading">\
|
||||
<div class="trash-container pull-right"></div>\
|
||||
<div class="trash-container pull-right"><button type="button" class="btn btn-link ' + step.name + ' dimension-tooltip" data-toggle="tooltip" data-html="true" title="" data-original-title=""><i class="fa fa-info-circle"></i></button></div>\
|
||||
<h3 class="panel-title">' +
|
||||
'<span class="toggle">' + step.name + ' <span class="caret toggleIcon rotated"></span>\
|
||||
'<span class="toggle mouse">' + step.name + ' <span class="caret toggleIcon rotated"></span>\
|
||||
<span class="load-spin pull-right" style="display:none;padding:1px 8px;"><i class="fa fa-circle-o-notch fa-spin"></i></span>\
|
||||
</h3>\
|
||||
</div>\
|
||||
@@ -56,7 +59,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
</div>';
|
||||
|
||||
var tools =
|
||||
'<div class="trash">\
|
||||
'<div class="trash" style="display: inline-block">\
|
||||
<button confirm="Are you sure?" class="remove btn btn-default btn-xs">\
|
||||
<i class="fa fa-trash"></i>\
|
||||
</button>\
|
||||
@@ -67,8 +70,14 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
var parser = new DOMParser();
|
||||
step.ui = parser.parseFromString(step.ui, 'text/html');
|
||||
step.ui = step.ui.querySelector('div.container-fluid');
|
||||
|
||||
$step = scopeQuery.scopeSelector(step.ui);
|
||||
$stepAll = scopeQuery.scopeSelectorAll(step.ui);
|
||||
step.ui.$step = $step;
|
||||
step.ui.$stepAll = $stepAll;
|
||||
|
||||
step.linkElements = step.ui.querySelectorAll('a');
|
||||
step.imgElement = step.ui.querySelector('a img.img-thumbnail');
|
||||
step.imgElement = $step('a img.img-thumbnail')[0];
|
||||
|
||||
if (_sequencer.modulesInfo().hasOwnProperty(step.name)) {
|
||||
var inputs = _sequencer.modulesInfo(step.name).inputs;
|
||||
@@ -144,12 +153,12 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
html +
|
||||
'\
|
||||
</div>';
|
||||
step.ui.querySelector('div.details').appendChild(div);
|
||||
$step('div.details').append(div);
|
||||
}
|
||||
$(step.ui.querySelector('div.panel-footer')).append(
|
||||
$step('div.panel-footer').append(
|
||||
'<div class="cal collapse in"><button type="submit" class="btn btn-sm btn-default btn-save" disabled = "true" >Apply</button> <small style="padding-top:2px;">Press apply to see changes</small></div>'
|
||||
);
|
||||
$(step.ui.querySelector('div.panel-footer')).prepend(
|
||||
$step('div.panel-footer').prepend(
|
||||
'<button class="pull-right btn btn-default btn-sm insert-step" >\
|
||||
<span class="insert-text"><i class="fa fa-plus"></i> Insert Step</span><span class="no-insert-text" style="display:none">Close</span></button>\
|
||||
<button class="pull-right btn btn-default btn-sm download-btn" style="margin-right:2px" >\
|
||||
@@ -159,39 +168,40 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
}
|
||||
|
||||
if (step.name != 'load-image') {
|
||||
step.ui
|
||||
.querySelector('div.trash-container')
|
||||
$step('div.trash-container')
|
||||
.prepend(
|
||||
parser.parseFromString(tools, 'text/html').querySelector('div')
|
||||
);
|
||||
$(step.ui.querySelectorAll('.remove')).on('click', function() {notify('Step Removed', 'remove-notification');});
|
||||
$(step.ui.querySelectorAll('.insert-step')).on('click', function() { util.insertStep(step.ID); });
|
||||
|
||||
$stepAll('.remove').on('click', function() {notify('Step Removed', 'remove-notification');});
|
||||
$stepAll('.insert-step').on('click', function() { util.insertStep(step.ID); });
|
||||
// Insert the step's UI in the right place
|
||||
if (stepOptions.index == _sequencer.steps.length) {
|
||||
stepsEl.appendChild(step.ui);
|
||||
$('#steps .step-container:nth-last-child(1) .insert-step').prop('disabled', true);
|
||||
if($('#steps .step-container:nth-last-child(2)'))
|
||||
$('#steps .step-container:nth-last-child(2) .insert-step').prop('disabled', false);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
stepsEl.insertBefore(step.ui, $(stepsEl).children()[stepOptions.index]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$('#load-image').append(step.ui);
|
||||
}
|
||||
$(step.ui.querySelector('.toggle')).on('click', () => {
|
||||
$(step.ui.querySelector('.toggleIcon')).toggleClass('rotated');
|
||||
$(step.ui.querySelectorAll('.cal')).collapse('toggle');
|
||||
$step('.toggle').on('click', () => {
|
||||
$step('.toggleIcon').toggleClass('rotated');
|
||||
$stepAll('.cal').collapse('toggle');
|
||||
});
|
||||
|
||||
$(step.imgElement).on('mousemove', _.debounce(() => imageHover(step), 150));
|
||||
$(step.imgElement).on('click', (e) => {e.preventDefault(); });
|
||||
$(step.ui.querySelectorAll('#color-picker')).colorpicker();
|
||||
$stepAll('#color-picker').colorpicker();
|
||||
|
||||
function saveOptions(e) {
|
||||
function saveOptions(e) { // 1. SAVE OPTIONS
|
||||
e.preventDefault();
|
||||
if (optionsChanged){
|
||||
$(step.ui.querySelector('div.details'))
|
||||
$step('div.details')
|
||||
.find('input,select')
|
||||
.each(function(i, input) {
|
||||
$(input)
|
||||
@@ -204,7 +214,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
// modify the url hash
|
||||
urlHash.setUrlHashParameter('steps', _sequencer.toString());
|
||||
// disable the save button
|
||||
$(step.ui.querySelector('.btn-save')).prop('disabled', true);
|
||||
$step('.btn-save').prop('disabled', true);
|
||||
optionsChanged = false;
|
||||
changedInputs = 0;
|
||||
}
|
||||
@@ -215,15 +225,15 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
changedInputs += hasChangedBefore ? inputChanged ? 0 : -1 : inputChanged ? 1 : 0;
|
||||
optionsChanged = changedInputs > 0;
|
||||
|
||||
$(step.ui.querySelector('.btn-save')).prop('disabled', !optionsChanged);
|
||||
$step('.btn-save').prop('disabled', !optionsChanged);
|
||||
return inputChanged;
|
||||
}
|
||||
|
||||
var
|
||||
changedInputs = 0,
|
||||
optionsChanged = false;
|
||||
$(step.ui.querySelector('.input-form')).on('submit', saveOptions);
|
||||
$(step.ui.querySelectorAll('.target')).each(function(i, input) {
|
||||
$step('.input-form').on('submit', saveOptions);
|
||||
$stepAll('.target').each(function(i, input) {
|
||||
$(input)
|
||||
.data('initValue', $(input).val())
|
||||
.data('hasChangedBefore', false)
|
||||
@@ -248,19 +258,19 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
}
|
||||
|
||||
|
||||
function onDraw(step) {
|
||||
$(step.ui.querySelector('.load')).show();
|
||||
$(step.ui.querySelector('img')).hide();
|
||||
$(step.ui.querySelectorAll('.load-spin')).show();
|
||||
function onDraw() {
|
||||
$step('.load').show();
|
||||
$step('img').hide();
|
||||
$stepAll('.load-spin').show();
|
||||
}
|
||||
|
||||
function onComplete(step) {
|
||||
$(step.ui.querySelector('img')).show();
|
||||
$(step.ui.querySelectorAll('.load-spin')).hide();
|
||||
$(step.ui.querySelector('.load')).hide();
|
||||
$step('img').show();
|
||||
$stepAll('.load-spin').hide();
|
||||
$step('.load').hide();
|
||||
|
||||
step.imgElement.src = (step.name == 'load-image') ? step.output.src : step.output;
|
||||
var imgthumbnail = step.ui.querySelector('.img-thumbnail');
|
||||
var imgthumbnail = $step('.img-thumbnail').getDomElem();
|
||||
for (let index = 0; index < step.linkElements.length; index++) {
|
||||
if (step.linkElements[index].contains(imgthumbnail))
|
||||
step.linkElements[index].href = step.imgElement.src;
|
||||
@@ -271,7 +281,7 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
return output.split('/')[1].split(';')[0];
|
||||
}
|
||||
|
||||
$(step.ui.querySelectorAll('.download-btn')).on('click', () => {
|
||||
$stepAll('.download-btn').on('click', () => {
|
||||
|
||||
for (let index = 0; index < step.linkElements.length; index++){
|
||||
|
||||
@@ -294,21 +304,28 @@ function DefaultHtmlStepUi(_sequencer, options) {
|
||||
for (var i in inputs) {
|
||||
if (step.options[i] !== undefined) {
|
||||
if (inputs[i].type.toLowerCase() === 'input')
|
||||
$(step.ui.querySelector('div[name="' + i + '"] input'))
|
||||
$step('div[name="' + i + '"] input')
|
||||
.val(step.options[i])
|
||||
.data('initValue', step.options[i]);
|
||||
if (inputs[i].type.toLowerCase() === 'select')
|
||||
$(step.ui.querySelector('div[name="' + i + '"] select'))
|
||||
$step('div[name="' + i + '"] select')
|
||||
.val(step.options[i])
|
||||
.data('initValue', step.options[i]);
|
||||
}
|
||||
}
|
||||
for (var i in outputs) {
|
||||
if (step[i] !== undefined)
|
||||
$(step.ui.querySelector('div[name="' + i + '"] input'))
|
||||
$step('div[name="' + i + '"] input')
|
||||
.val(step[i]);
|
||||
}
|
||||
}
|
||||
|
||||
$(function () {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
_sequencer.getImageDimensions(step.imgElement.src, function (dim) {
|
||||
step.ui.querySelector('.' + step.name).attributes['data-original-title'].value = `<div style="text-align: center"><p>Image Width: ${dim.width}<br>Image Height: ${dim.height}</br></div>`;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function imageHover(step){
|
||||
|
||||
@@ -23,7 +23,10 @@ function generatePreview(previewStepName, customValues, path, selector) {
|
||||
previewSequencer.addSteps(previewStepName, { [previewStepName]: customValues }).run(insertPreview);
|
||||
}
|
||||
}
|
||||
previewSequencer.loadImage(path, loadPreview);
|
||||
if(previewStepName === 'resize')
|
||||
insertPreview(path);
|
||||
else
|
||||
previewSequencer.loadImage(path, loadPreview);
|
||||
}
|
||||
|
||||
function updatePreviews(src, selector) {
|
||||
@@ -44,11 +47,30 @@ function updatePreviews(src, selector) {
|
||||
}
|
||||
};
|
||||
|
||||
Object.keys(previewSequencerSteps).forEach(function (step, index) {
|
||||
generatePreview(step, Object.values(previewSequencerSteps)[index], src, selector);
|
||||
});
|
||||
var img = new Image();
|
||||
img.onload = function(){
|
||||
var height = img.height;
|
||||
var width = img.width;
|
||||
|
||||
let percentage = (80 / height) * 100; //take the min resize value that fits the preview area => (new-width/orig_ht) - '80 as the preview area has 80*80 dimension
|
||||
percentage = Math.max((80 / width) * 100, percentage); // make sure that one dimension doesn't resize greater, leading distorting preview-area fitting
|
||||
percentage = Math.ceil(percentage);
|
||||
|
||||
var sequencer = ImageSequencer();
|
||||
|
||||
sequencer.loadImage(src, function(){
|
||||
this.addSteps('resize', {['resize']: percentage + '%'});
|
||||
this.run((src)=>{
|
||||
Object.keys(previewSequencerSteps).forEach(function (step, index) {
|
||||
generatePreview(step, Object.values(previewSequencerSteps)[index], src, selector);
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
img.src = src;
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
generatePreview : generatePreview,
|
||||
updatePreviews : updatePreviews
|
||||
|
||||
@@ -64,33 +64,25 @@ function IntermediateHtmlStepUi(_sequencer, step, options) {
|
||||
</div>';
|
||||
}
|
||||
|
||||
|
||||
function selectNewStepUi() {
|
||||
var insertSelect = $(step.ui.querySelector('.insert-step-select'));
|
||||
var m = insertSelect.val();
|
||||
$(step.ui.querySelector('.insertDiv .info')).html(_sequencer.modulesInfo(m).description);
|
||||
$(step.ui.querySelector('.insertDiv .add-step-btn')).prop('disabled', false);
|
||||
}
|
||||
|
||||
|
||||
var toggleDiv = function(callback = function(){}){
|
||||
$(step.ui.querySelector('.insertDiv')).collapse('toggle');
|
||||
if ($(step.ui.querySelector('.insert-text')).css('display') != 'none'){
|
||||
$(step.ui.querySelector('.insert-text')).fadeToggle(200, function(){$(step.ui.querySelector('.no-insert-text')).fadeToggle(200, callback);});
|
||||
var toggleDiv = function($step, callback = function(){}){
|
||||
$step('.insertDiv').collapse('toggle');
|
||||
if ($step('.insert-text').css('display') != 'none'){
|
||||
$step('.insert-text').fadeToggle(200, function(){$step('.no-insert-text').fadeToggle(200, callback);});
|
||||
}
|
||||
else {
|
||||
$(step.ui.querySelector('.no-insert-text')).fadeToggle(200, function(){$(step.ui.querySelector('.insert-text')).fadeToggle(200, callback);});
|
||||
$step('.no-insert-text').fadeToggle(200, function(){$step('.insert-text').fadeToggle(200, callback);});
|
||||
}
|
||||
};
|
||||
|
||||
insertStep = function (id) {
|
||||
const $step = step.ui.$step,
|
||||
$stepAll = step.ui.$stepAll;
|
||||
var modulesInfo = _sequencer.modulesInfo();
|
||||
var parser = new DOMParser();
|
||||
var addStepUI = stepUI();
|
||||
addStepUI = parser.parseFromString(addStepUI, 'text/html').querySelector('div');
|
||||
|
||||
if ($(step.ui.querySelector('.insertDiv')).length > 0){
|
||||
toggleDiv();
|
||||
if ($step('.insertDiv').length > 0){
|
||||
toggleDiv($step);
|
||||
}
|
||||
else {
|
||||
step.ui
|
||||
@@ -98,18 +90,21 @@ function IntermediateHtmlStepUi(_sequencer, step, options) {
|
||||
.insertAdjacentElement('afterend',
|
||||
addStepUI
|
||||
);
|
||||
toggleDiv(function(){
|
||||
toggleDiv($step, function(){
|
||||
insertPreview.updatePreviews(step.output, '.insertDiv');
|
||||
});
|
||||
}
|
||||
|
||||
$(step.ui.querySelector('.insertDiv .close-insert-box')).off('click').on('click', function(){toggleDiv(function(){});});
|
||||
$step('.insertDiv .close-insert-box').off('click').on('click', function(){
|
||||
toggleDiv($step);
|
||||
$step('.insertDiv').removeClass('insertDiv');
|
||||
});
|
||||
|
||||
var insertStepSelect = $(step.ui.querySelector('.insert-step-select'));
|
||||
var insertStepSelect = $step('.insert-step-select');
|
||||
insertStepSelect.html('');
|
||||
// Add modules to the insertStep dropdown
|
||||
for (var m in modulesInfo) {
|
||||
if (modulesInfo[m] !== undefined)
|
||||
if (modulesInfo[m] && modulesInfo[m].name)
|
||||
insertStepSelect.append(
|
||||
'<option value="' + m + '">' + modulesInfo[m].name + '</option>'
|
||||
);
|
||||
@@ -117,47 +112,26 @@ function IntermediateHtmlStepUi(_sequencer, step, options) {
|
||||
insertStepSelect.selectize({
|
||||
sortField: 'text'
|
||||
});
|
||||
$(step.ui.querySelector('.inserDiv .add-step-btn')).prop('disabled', true);
|
||||
|
||||
insertStepSelect.append('<option value="" disabled selected>Select a Module</option>');
|
||||
$(step.ui.querySelector('.insertDiv .radio-group .radio')).on('click', function () {
|
||||
$(this).parent().find('.radio').removeClass('selected');
|
||||
$(this).addClass('selected');
|
||||
newStep = $(this).attr('data-value');
|
||||
$(step.ui.querySelector('.insert-step-select')).val(newStep);
|
||||
selectNewStepUi();
|
||||
insert(id);
|
||||
$(this).removeClass('selected');
|
||||
$('.insertDiv .radio-group .radio').on('click', function () {
|
||||
var newStepName = $(this).attr('data-value');
|
||||
id = $($step('.insertDiv').parents()[3]).prevAll().length;
|
||||
insert(id, $step, newStepName);
|
||||
});
|
||||
insertStepSelect.on('change', selectNewStepUi);
|
||||
$(step.ui.querySelector('.insertDiv .add-step-btn')).on('click', function () { insert(id); });
|
||||
$step('.insertDiv .add-step-btn').on('click', function () {
|
||||
var newStepName = insertStepSelect.val();
|
||||
id = $($step('.insertDiv').parents()[3]).prevAll().length;
|
||||
insert(id, $step, newStepName); });
|
||||
};
|
||||
|
||||
function insert(id) {
|
||||
|
||||
options = options || {};
|
||||
var insertStepSelect = $(step.ui.querySelector('.insert-step-select'));
|
||||
if (insertStepSelect.val() == 'none') return;
|
||||
|
||||
var newStepName = insertStepSelect.val();
|
||||
toggleDiv();
|
||||
var sequenceLength = 1;
|
||||
if (sequencer.sequences[newStepName]) {
|
||||
sequenceLength = sequencer.sequences[newStepName].length;
|
||||
} else if (sequencer.modules[newStepName][1]['length']) {
|
||||
sequenceLength = sequencer.modules[newStepName][1]['length'];
|
||||
}
|
||||
_sequencer
|
||||
.insertSteps(id + 1, newStepName).run({ index: id });
|
||||
|
||||
// add to URL hash too
|
||||
function insert(id, $step, newStepName) {
|
||||
toggleDiv($step);
|
||||
$step('.insertDiv').removeClass('insertDiv');
|
||||
_sequencer.insertSteps(id + 1, newStepName).run({ index: id });
|
||||
urlHash.setUrlHashParameter('steps', _sequencer.toString());
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
insertStep
|
||||
};
|
||||
}
|
||||
module.exports = IntermediateHtmlStepUi;
|
||||
|
||||
module.exports = IntermediateHtmlStepUi;
|
||||
68
examples/lib/scopeQuery.js
Normal file
68
examples/lib/scopeQuery.js
Normal file
@@ -0,0 +1,68 @@
|
||||
/**
|
||||
* @method $scope
|
||||
* @param {"DOMNode"} scope A DOM Node as the scope
|
||||
*/
|
||||
function $scope(scope) {
|
||||
return function(queryString){
|
||||
var element = $(scope.querySelector(queryString));
|
||||
|
||||
element.elem = function(queryString){
|
||||
return new $scope(scope)(queryString);
|
||||
};
|
||||
element.elemAll = function(queryString){
|
||||
return new $scopeAll(scope)(queryString);
|
||||
};
|
||||
element.getDomElem = function(i = 0){
|
||||
return element[i];
|
||||
};
|
||||
element.getScope = () => scope;
|
||||
|
||||
return element;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @method $scopeAll
|
||||
* @param {"DOMNode"} scope A DOM Node as the scope
|
||||
*/
|
||||
function $scopeAll(scope){
|
||||
return function(queryString){
|
||||
var element = $(scope.querySelectorAll(queryString));
|
||||
|
||||
element.elem = function(queryString){
|
||||
return new $scope(scope)(queryString);
|
||||
};
|
||||
element.elemAll = function(queryString){
|
||||
return new $scopeAll(scope)(queryString);
|
||||
};
|
||||
element.getDomElem = function(i = 0){
|
||||
return element[i];
|
||||
};
|
||||
element.getScope = () => scope;
|
||||
|
||||
return element;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @method scopeSelector
|
||||
* @description A scoped jQuery selector
|
||||
* @param {"DOMNode"} scope DOM Node as the scope
|
||||
*/
|
||||
function scopeSelector(scope){
|
||||
return $scope(scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* @method scopeSelectorAll
|
||||
* @description A scoped jQuery multiple selector
|
||||
* @param {"DOMNode} scope DOM Node as the scope
|
||||
*/
|
||||
function scopeSelectorAll(scope){
|
||||
return $scopeAll(scope);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
scopeSelector,
|
||||
scopeSelectorAll
|
||||
};
|
||||
3206
package-lock.json
generated
3206
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
23
package.json
23
package.json
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "image-sequencer",
|
||||
"version": "3.5.0",
|
||||
"version": "3.5.1",
|
||||
"description": "A modular JavaScript image manipulation library modeled on a storyboard.",
|
||||
"main": "src/ImageSequencer.js",
|
||||
"scripts": {
|
||||
"debug": "TEST=true node ./index.js -i ./examples/images/monarch.png -s invert",
|
||||
"test": "TEST=true istanbul cover tape test/core/*.js test/core/ui/user-interface.js test/core/modules/*.js | tap-spec; node test/core/sequencer/benchmark.js; browserify test/core/sequencer/meta-modules.js test/core/sequencer/image-sequencer.js test/core/sequencer/chain.js test/core/sequencer/replace.js test/core/sequencer/import-export.js test/core/sequencer/run.js test/core/sequencer/dynamic-imports.js test/core/util/*.js | tape-run --render=\"tap-spec\"",
|
||||
"test-ui": "node node_modules/jasmine/bin/jasmine test/spec/*.js",
|
||||
"test-ui": "node node_modules/jasmine/bin/jasmine test/ui/spec/*.js",
|
||||
"setup": "npm i && npm i -g grunt grunt-cli && grunt build",
|
||||
"start": "grunt serve"
|
||||
},
|
||||
@@ -30,14 +30,16 @@
|
||||
"url": "https://github.com/publiclab/image-sequencer/issues"
|
||||
},
|
||||
"dependencies": {
|
||||
"atob": "^2.1.2",
|
||||
"base64-img": "^1.0.4",
|
||||
"bootstrap": "~3.4.0",
|
||||
"bootstrap-colorpicker": "^2.5.3",
|
||||
"buffer": "~5.2.1",
|
||||
"commander": "^2.11.0",
|
||||
"buffer": "~5.4.0",
|
||||
"commander": "^3.0.1",
|
||||
"compressorjs": "^1.0.5",
|
||||
"data-uri-to-buffer": "^2.0.0",
|
||||
"downloadjs": "^1.4.7",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint": "^6.1.0",
|
||||
"fisheyegl": "^0.1.2",
|
||||
"font-awesome": "~4.7.0",
|
||||
"geotiff": "^1.0.0-beta.6",
|
||||
@@ -47,6 +49,9 @@
|
||||
"gpu.js": "^2.0.0-rc.12",
|
||||
"image-sequencer-invert": "^1.0.0",
|
||||
"imagejs": "0.0.9",
|
||||
"imagemin": "^7.0.0",
|
||||
"imagemin-jpegtran": "^6.0.0",
|
||||
"imagemin-pngquant": "^8.0.0",
|
||||
"imgareaselect": "git://github.com/jywarren/imgareaselect.git#v1.0.0-rc.2",
|
||||
"istanbul": "^0.4.5",
|
||||
"jasmine": "^3.4.0",
|
||||
@@ -55,6 +60,7 @@
|
||||
"jsqr": "^1.1.1",
|
||||
"lodash": "^4.17.11",
|
||||
"ndarray": "^1.0.18",
|
||||
"opencv.js": "^1.2.1",
|
||||
"ora": "^3.0.0",
|
||||
"pace": "0.0.4",
|
||||
"puppeteer": "^1.14.0",
|
||||
@@ -62,6 +68,7 @@
|
||||
"readline-sync": "^1.4.7",
|
||||
"save-pixels": "~2.3.4",
|
||||
"selectize": "^0.12.6",
|
||||
"spawn-sync": "^2.0.0",
|
||||
"urify": "^2.1.1",
|
||||
"webgl-distort": "0.0.2"
|
||||
},
|
||||
@@ -71,20 +78,20 @@
|
||||
"@babel/plugin-syntax-object-rest-spread": "^7.2.0",
|
||||
"babelify": "^10.0.0",
|
||||
"browserify": "16.2.3",
|
||||
"eslint": "^5.16.0",
|
||||
"eslint": "^6.1.0",
|
||||
"grunt": "^1.0.3",
|
||||
"grunt-browser-sync": "^2.2.0",
|
||||
"grunt-browserify": "^5.0.0",
|
||||
"grunt-contrib-concat": "^1.0.1",
|
||||
"grunt-contrib-uglify-es": "^3.3.0",
|
||||
"grunt-contrib-watch": "^1.1.0",
|
||||
"husky": "^2.2.0",
|
||||
"husky": "^3.0.5",
|
||||
"image-filter-core": "~2.0.2",
|
||||
"image-filter-threshold": "~2.0.1",
|
||||
"jasmine-core": "^3.3.0",
|
||||
"jasmine-jquery": "^2.1.1",
|
||||
"jasmine-spec-reporter": "^4.2.1",
|
||||
"lint-staged": "^8.1.6",
|
||||
"lint-staged": "^9.1.0",
|
||||
"looks-same": "^7.0.0",
|
||||
"matchdep": "^2.0.0",
|
||||
"tap-spec": "^5.0.0",
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
describe('Preview UI HTML', function() {
|
||||
|
||||
var InsertPreview = require('../examples/lib/insertPreview');
|
||||
var sequencer = require('../src/ImageSequencer')();
|
||||
var insertPreview;
|
||||
var options = { brightness: 50 };
|
||||
|
||||
beforeEach(()=>{
|
||||
insertPreview = InsertPreview;
|
||||
|
||||
spyOn(insertPreview, 'generatePreview');
|
||||
spyOn(insertPreview, 'updatePreviews');
|
||||
|
||||
insertPreview.generatePreview('brightness', options, 'src', 'selector');
|
||||
insertPreview.updatePreviews('src', 'selector');
|
||||
});
|
||||
|
||||
it('generate preview ui', function() {
|
||||
expect(insertPreview.generatePreview).toHaveBeenCalledWith('brightness', options, 'src', 'selector');
|
||||
});
|
||||
|
||||
it('update preview ui', function() {
|
||||
expect(insertPreview.updatePreviews).toHaveBeenCalledWith('src', 'selector');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,19 +0,0 @@
|
||||
describe('Intermediate step HTML', function() {
|
||||
|
||||
var IntermediateHtmlStepUi = require('../examples/lib/intermediateHtmlStepUi');
|
||||
var sequencer = require('../src/ImageSequencer')();
|
||||
var intermediateHtmlStepUi;
|
||||
|
||||
beforeEach(()=>{
|
||||
intermediateHtmlStepUi = new IntermediateHtmlStepUi(sequencer);
|
||||
|
||||
spyOn(intermediateHtmlStepUi, 'insertStep');
|
||||
|
||||
intermediateHtmlStepUi.insertStep();
|
||||
});
|
||||
|
||||
it('insert step ui', function() {
|
||||
expect(intermediateHtmlStepUi.insertStep).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,11 +0,0 @@
|
||||
{
|
||||
"spec_dir": "spec",
|
||||
"spec_files": [
|
||||
"**/*[sS]pec.js"
|
||||
],
|
||||
"helpers": [
|
||||
"helpers/**/*.js"
|
||||
],
|
||||
"stopSpecOnExpectationFailure": false,
|
||||
"random": true
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
describe('URL manipulation methods', function() {
|
||||
|
||||
var UrlHash = require('../examples/lib/urlHash');
|
||||
var urlHash;
|
||||
var params = {
|
||||
module: 'brightness',
|
||||
brightness: 50
|
||||
};
|
||||
|
||||
beforeEach(()=>{
|
||||
urlHash = UrlHash;
|
||||
|
||||
spyOn(urlHash, 'getUrlHashParameters');
|
||||
spyOn(urlHash, 'getUrlHashParameter');
|
||||
spyOn(urlHash, 'setUrlHashParameters');
|
||||
spyOn(urlHash, 'setUrlHashParameter');
|
||||
|
||||
urlHash.getUrlHashParameters();
|
||||
urlHash.getUrlHashParameter('module');
|
||||
urlHash.setUrlHashParameters(params);
|
||||
urlHash.setUrlHashParameter('module', 'brightness');
|
||||
});
|
||||
|
||||
it('gets url hash params from window hash', function() {
|
||||
expect(urlHash.getUrlHashParameters).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('gets url hash param from params object', function() {
|
||||
expect(urlHash.getUrlHashParameter).toHaveBeenCalledWith('module');
|
||||
});
|
||||
|
||||
it('accepts param object and sets url hash params', function() {
|
||||
expect(urlHash.setUrlHashParameters).toHaveBeenCalledWith(params);
|
||||
});
|
||||
|
||||
it('accepts param key-value pair and sets url hash params', function() {
|
||||
expect(urlHash.setUrlHashParameter).toHaveBeenCalledWith('module', 'brightness');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -4,6 +4,8 @@ require('./util/getStep.js');
|
||||
|
||||
ImageSequencer = function ImageSequencer(options) {
|
||||
|
||||
var str = require('./Strings.js')(this.steps, modulesInfo, addSteps, copy);
|
||||
|
||||
var sequencer = (this.name == 'ImageSequencer') ? this : this.sequencer;
|
||||
options = options || {};
|
||||
options.inBrowser = options.inBrowser === undefined ? isBrowser : options.inBrowser;
|
||||
@@ -256,8 +258,8 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
fs.writeFileSync('./src/Modules.js', mods);
|
||||
}
|
||||
|
||||
function saveSequence(name, sequenceString) {
|
||||
const sequence = stringToJSON(sequenceString);
|
||||
function saveSequence(name, sequenceString) { // 4. save sequence
|
||||
const sequence = str.stringToJSON(sequenceString);
|
||||
// Save the given sequence string as a module
|
||||
if (options.inBrowser) {
|
||||
// Inside the browser we save the meta-modules using the Web Storage API
|
||||
@@ -282,7 +284,6 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
this.sequences = require('./SavedSequences.json');
|
||||
}
|
||||
|
||||
var str = require('./Strings.js')(this.steps, modulesInfo, addSteps, copy);
|
||||
|
||||
return {
|
||||
//literals and objects
|
||||
@@ -328,6 +329,7 @@ ImageSequencer = function ImageSequencer(options) {
|
||||
log: log,
|
||||
objTypeOf: objTypeOf,
|
||||
copy: copy,
|
||||
getImageDimensions: require('./util/getImageDimensions'),
|
||||
|
||||
setInputStep: require('./ui/SetInputStep')(sequencer)
|
||||
};
|
||||
|
||||
@@ -5,6 +5,7 @@ module.exports = {
|
||||
'add-qr': require('./modules/AddQR'),
|
||||
'average': require('./modules/Average'),
|
||||
'blend': require('./modules/Blend'),
|
||||
'blob-analysis': require('./modules/BlobAnalysis'),
|
||||
'blur': require('./modules/Blur'),
|
||||
'brightness': require('./modules/Brightness'),
|
||||
'canvas-resize': require('./modules/CanvasResize'),
|
||||
@@ -28,6 +29,7 @@ module.exports = {
|
||||
'gradient': require('./modules/Gradient'),
|
||||
'grid-overlay': require('./modules/GridOverlay'),
|
||||
'import-image': require('./modules/ImportImage'),
|
||||
'minify-image': require('./modules/MinifyImage'),
|
||||
'invert': require('image-sequencer-invert'),
|
||||
'ndvi': require('./modules/Ndvi'),
|
||||
'ndvi-colormap': require('./modules/NdviColormap'),
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
module.exports = exports = function (options, pixels, oldPixels, callback) {
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
var QRCode = require('qrcode');
|
||||
QRCode.toDataURL(options.qrCodeString, function (err, url) {
|
||||
var getPixels = require('get-pixels');
|
||||
@@ -26,17 +28,11 @@ module.exports = exports = function (options, pixels, oldPixels, callback) {
|
||||
for (var m = 0; m < width; m++) {
|
||||
for (var n = 0; n < height; n++) {
|
||||
if (m >= xe && n >= ye) {
|
||||
pixels.set(m, n, 0, qrPixels.get(m - xe, n - ye, 0));
|
||||
pixels.set(m, n, 1, qrPixels.get(m - xe, n - ye, 1));
|
||||
pixels.set(m, n, 2, qrPixels.get(m - xe, n - ye, 2));
|
||||
pixels.set(m, n, 3, qrPixels.get(m - xe, n - ye, 3));
|
||||
pixelSetter(m, n, [qrPixels.get(m - xe, n - ye, 0), qrPixels.get(m - xe, n - ye, 1), qrPixels.get(m - xe, n - ye, 2), qrPixels.get(m - xe, n - ye, 3)], pixels);
|
||||
}
|
||||
|
||||
else {
|
||||
pixels.set(m, n, 0, oldPixels.get(m, n, 0));
|
||||
pixels.set(m, n, 1, oldPixels.get(m, n, 1));
|
||||
pixels.set(m, n, 2, oldPixels.get(m, n, 2));
|
||||
pixels.set(m, n, 3, oldPixels.get(m, n, 3));
|
||||
pixelSetter(m, n, [oldPixels.get(m, n, 0), oldPixels.get(m, n, 1), oldPixels.get(m, n, 2), oldPixels.get(m, n, 3)], pixels);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ module.exports = function Average(options, UI) {
|
||||
|
||||
// do the averaging
|
||||
function extraManipulation(pixels) {
|
||||
const $ = window.$;
|
||||
var i = 0, sum = [0, 0, 0, 0];
|
||||
while (i < pixels.data.length) {
|
||||
sum[0] += pixels.data[i++];
|
||||
|
||||
81
src/modules/BlobAnalysis/BlobAnalysis.js
Normal file
81
src/modules/BlobAnalysis/BlobAnalysis.js
Normal file
@@ -0,0 +1,81 @@
|
||||
module.exports = function(pixels, options, priorStep){
|
||||
|
||||
var $ = require('jquery'); // to make Blob-analysis work for node.js
|
||||
|
||||
var img = $(priorStep.imgElement);
|
||||
if(Object.keys(img).length === 0){
|
||||
img = $(priorStep.options.step.imgElement);
|
||||
}
|
||||
|
||||
var canvas = document.createElement('canvas');
|
||||
canvas.width = pixels.shape[0];
|
||||
canvas.height = pixels.shape[1];
|
||||
var ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(img[0], 0, 0);
|
||||
let imgData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||
|
||||
|
||||
let src = cv.matFromImageData(imgData);
|
||||
let dst = new cv.Mat();
|
||||
let gray = new cv.Mat();
|
||||
let opening = new cv.Mat();
|
||||
let imageBg = new cv.Mat();
|
||||
let imageFg = new cv.Mat();
|
||||
let distTrans = new cv.Mat();
|
||||
let unknown = new cv.Mat();
|
||||
let markers = new cv.Mat();
|
||||
|
||||
// gray and threshold image
|
||||
cv.cvtColor(src, gray, cv.COLOR_RGBA2GRAY, 0);
|
||||
cv.threshold(gray, gray, 0, 255, cv.THRESH_BINARY_INV + cv.THRESH_OTSU);
|
||||
|
||||
// get background
|
||||
let M = cv.Mat.ones(3, 3, cv.CV_8U);
|
||||
cv.erode(gray, gray, M);
|
||||
cv.dilate(gray, opening, M);
|
||||
cv.dilate(opening, imageBg, M, new cv.Point(-1, -1), 3);
|
||||
|
||||
// distance transform
|
||||
cv.distanceTransform(opening, distTrans, cv.DIST_L2, 5);
|
||||
cv.normalize(distTrans, distTrans, 1, 0, cv.NORM_INF);
|
||||
|
||||
// get foreground
|
||||
cv.threshold(distTrans, imageFg, 0.7 * 1, 255, cv.THRESH_BINARY);
|
||||
imageFg.convertTo(imageFg, cv.CV_8U, 1, 0);
|
||||
cv.subtract(imageBg, imageFg, unknown);
|
||||
|
||||
// get connected components markers
|
||||
cv.connectedComponents(imageFg, markers);
|
||||
for (let i = 0; i < markers.rows; i++) {
|
||||
for (let j = 0; j < markers.cols; j++) {
|
||||
markers.intPtr(i, j)[0] = markers.ucharPtr(i, j)[0] + 1;
|
||||
if (unknown.ucharPtr(i, j)[0] == 255) {
|
||||
markers.intPtr(i, j)[0] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cv.cvtColor(src, src, cv.COLOR_RGBA2RGB, 0);
|
||||
cv.watershed(src, markers);
|
||||
|
||||
// draw barriers
|
||||
for (let i = 0; i < markers.rows; i++) {
|
||||
for (let j = 0; j < markers.cols; j++) {
|
||||
if (markers.intPtr(i, j)[0] == -1) {
|
||||
src.ucharPtr(i, j)[0] = 255; // R
|
||||
src.ucharPtr(i, j)[1] = 0; // G
|
||||
src.ucharPtr(i, j)[2] = 0; // B
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cv.imshow(canvas, src);
|
||||
|
||||
src.delete(); dst.delete(); gray.delete(); opening.delete(); imageBg.delete();
|
||||
imageFg.delete(); distTrans.delete(); unknown.delete(); markers.delete(); M.delete();
|
||||
|
||||
var myImageData = ctx.getImageData(0, 0, canvas.width, canvas.height);
|
||||
pixels.data = myImageData.data;
|
||||
|
||||
return pixels;
|
||||
};
|
||||
43
src/modules/BlobAnalysis/Module.js
Normal file
43
src/modules/BlobAnalysis/Module.js
Normal file
@@ -0,0 +1,43 @@
|
||||
|
||||
module.exports = function BlobAnalysis(options, UI){
|
||||
|
||||
var output;
|
||||
|
||||
function draw(input, callback, progressObj) {
|
||||
|
||||
progressObj.stop(true);
|
||||
progressObj.overrideFlag = true;
|
||||
|
||||
var step = this;
|
||||
|
||||
var priorStep = this.getStep(-1); // get the previous step to process it
|
||||
|
||||
function extraManipulation(pixels){
|
||||
|
||||
pixels = require('./BlobAnalysis')(pixels, options, priorStep);
|
||||
return pixels;
|
||||
}
|
||||
|
||||
function output(image, datauri, mimetype){
|
||||
|
||||
step.output = { src: datauri, format: mimetype};
|
||||
}
|
||||
|
||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||
output: output,
|
||||
extraManipulation: extraManipulation,
|
||||
format: input.format,
|
||||
image: options.image,
|
||||
inBrowser: options.inBrowser,
|
||||
callback: callback
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
options: options,
|
||||
draw: draw,
|
||||
output: output,
|
||||
UI: UI
|
||||
};
|
||||
};
|
||||
4
src/modules/BlobAnalysis/index.js
Normal file
4
src/modules/BlobAnalysis/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = [
|
||||
require('./Module'),
|
||||
require('./info.json')
|
||||
];
|
||||
6
src/modules/BlobAnalysis/info.json
Normal file
6
src/modules/BlobAnalysis/info.json
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"name": "Blob Analysis",
|
||||
"description": "Blob/Region identification for microscopic images.",
|
||||
"inputs": {},
|
||||
"docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md#blob-analysis"
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
module.exports = exports = function(pixels, blur) {
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
let kernel = kernelGenerator(blur),
|
||||
pixs = {
|
||||
r: [],
|
||||
@@ -24,9 +26,10 @@ module.exports = exports = function(pixels, blur) {
|
||||
|
||||
for (let y = 0; y < pixels.shape[1]; y++){
|
||||
for (let x = 0; x < pixels.shape[0]; x++){
|
||||
pixels.set(x, y, 0, Math.max(0, Math.min(conPix[0][y][x], 255)));
|
||||
pixels.set(x, y, 1, Math.max(0, Math.min(conPix[1][y][x], 255)));
|
||||
pixels.set(x, y, 2, Math.max(0, Math.min(conPix[2][y][x], 255)));
|
||||
var pixelvalue = [Math.max(0, Math.min(conPix[0][y][x], 255)),
|
||||
Math.max(0, Math.min(conPix[1][y][x], 255)),
|
||||
Math.max(0, Math.min(conPix[2][y][x], 255))];
|
||||
pixelSetter(x, y, pixelvalue, pixels);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
module.exports = function canvasResize(options, UI) {
|
||||
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
var output;
|
||||
|
||||
|
||||
|
||||
function draw(input, callback, progressObj) {
|
||||
|
||||
options.width = parseInt(options.width || defaults.width);
|
||||
@@ -21,16 +21,15 @@ module.exports = function canvasResize(options, UI) {
|
||||
var step = this;
|
||||
|
||||
function extraManipulation(pixels) {
|
||||
|
||||
let newPixels = require('ndarray')(new Uint8Array(4 * options.width * options.height).fill(0), [options.width, options.height, 4]);
|
||||
let iMax = options.width - options.x,
|
||||
jMax = options.height - options.y;
|
||||
for (let i = 0; i < iMax && i < pixels.shape[0]; i++) {
|
||||
for (let j = 0; j < jMax && j < pixels.shape[1]; j++) {
|
||||
let x = i + options.x, y = j + options.y;
|
||||
newPixels.set(x, y, 0, pixels.get(i, j, 0));
|
||||
newPixels.set(x, y, 1, pixels.get(i, j, 1));
|
||||
newPixels.set(x, y, 2, pixels.get(i, j, 2));
|
||||
newPixels.set(x, y, 3, pixels.get(i, j, 3));
|
||||
pixelSetter(x, y, [pixels.get(i, j, 0), pixels.get(i, j, 1), pixels.get(i, j, 2), pixels.get(i, j, 3)], newPixels);
|
||||
|
||||
}
|
||||
}
|
||||
return newPixels;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
module.exports = function ColorTemperature(options, UI) {
|
||||
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
var output;
|
||||
|
||||
@@ -38,17 +40,12 @@ module.exports = function ColorTemperature(options, UI) {
|
||||
for (let i = 0; i < pixels.shape[0]; i++) {
|
||||
for (let j = 0; j < pixels.shape[1]; j++) {
|
||||
|
||||
r_data = pixels.get(i, j, 0);
|
||||
r_new_data = (255 / r) * r_data;
|
||||
pixels.set(i, j, 0, r_new_data);
|
||||
var rgbdata = [pixels.get(i, j, 0), pixels.get(i, j, 1), pixels.get(i, j, 2)];
|
||||
rgbdata[0] = (255 / r) * rgbdata[0];
|
||||
rgbdata[1] = (255 / g) * rgbdata[1];
|
||||
rgbdata[2] = (255 / b) * rgbdata[2];
|
||||
pixelSetter(i, j, rgbdata, pixels);
|
||||
|
||||
g_data = pixels.get(i, j, 1);
|
||||
g_new_data = (255 / g) * g_data;
|
||||
pixels.set(i, j, 1, g_new_data);
|
||||
|
||||
b_data = pixels.get(i, j, 2);
|
||||
b_new_data = (255 / b) * b_data;
|
||||
pixels.set(i, j, 2, b_new_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
var _ = require('lodash');
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
module.exports = exports = function(pixels, contrast) {
|
||||
let oldpix = _.cloneDeep(pixels);
|
||||
@@ -10,37 +11,19 @@ module.exports = exports = function(pixels, contrast) {
|
||||
|
||||
for (let i = 0; i < pixels.shape[0]; i++) {
|
||||
for (let j = 0; j < pixels.shape[1]; j++) {
|
||||
var r = oldpix.get(i, j, 0) / 255.0;
|
||||
r -= 0.5;
|
||||
r *= contrast;
|
||||
r += 0.5;
|
||||
r *= 255;
|
||||
if (r < 0) r = 0;
|
||||
if (r > 255) r = 255;
|
||||
|
||||
|
||||
var g = oldpix.get(i, j, 1) / 255.0;
|
||||
g -= 0.5;
|
||||
g *= contrast;
|
||||
g += 0.5;
|
||||
g *= 255;
|
||||
if (g < 0) g = 0;
|
||||
if (g > 255) g = 255;
|
||||
|
||||
|
||||
var b = oldpix.get(i, j, 2) / 255.0;
|
||||
b -= 0.5;
|
||||
b *= contrast;
|
||||
b += 0.5;
|
||||
b *= 255;
|
||||
if (b < 0) b = 0;
|
||||
if (b > 255) b = 255;
|
||||
|
||||
|
||||
pixels.set(i, j, 0, r);
|
||||
pixels.set(i, j, 1, g);
|
||||
pixels.set(i, j, 2, b);
|
||||
|
||||
|
||||
var rgbarray = [oldpix.get(i, j, 0) / 255.0, oldpix.get(i, j, 1) / 255.0, oldpix.get(i, j, 2) / 255.0];
|
||||
for(var idx = 0;idx < 3;idx++){
|
||||
rgbarray[idx] -= 0.5;
|
||||
rgbarray[idx] *= contrast;
|
||||
rgbarray[idx] += 0.5;
|
||||
rgbarray[idx] *= 255;
|
||||
if (rgbarray[idx] < 0) rgbarray[idx] = 0;
|
||||
if (rgbarray[idx] > 255) rgbarray[idx] = 255;
|
||||
}
|
||||
|
||||
pixelSetter(i, j, rgbarray, pixels);
|
||||
|
||||
}
|
||||
}
|
||||
return pixels;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
var _ = require('lodash');
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
module.exports = exports = function(pixels, constantFactor, kernelValues, texMode) {
|
||||
let kernel = kernelGenerator(constantFactor, kernelValues),
|
||||
pixs = {
|
||||
@@ -24,9 +26,8 @@ module.exports = exports = function(pixels, constantFactor, kernelValues, texMod
|
||||
|
||||
for (let y = 0; y < pixels.shape[1]; y++){
|
||||
for (let x = 0; x < pixels.shape[0]; x++){
|
||||
pixels.set(x, y, 0, Math.max(0, Math.min(conPix[0][y][x], 255)));
|
||||
pixels.set(x, y, 1, Math.max(0, Math.min(conPix[1][y][x], 255)));
|
||||
pixels.set(x, y, 2, Math.max(0, Math.min(conPix[2][y][x], 255)));
|
||||
var value = [Math.max(0, Math.min(conPix[0][y][x], 255)), Math.max(0, Math.min(conPix[1][y][x], 255)), Math.max(0, Math.min(conPix[2][y][x], 255))];
|
||||
pixelSetter(x, y, value, pixels);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
module.exports = exports = function(pixels, options){
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
options.startingX = options.startingX || defaults.startingX;
|
||||
options.startingY = options.startingY || defaults.startingY;
|
||||
@@ -17,10 +18,8 @@ module.exports = exports = function(pixels, options){
|
||||
var drawSide = function(startX, startY, endX, endY){
|
||||
for (var n = startX; n <= endX + thickness; n++){
|
||||
for (var k = startY; k <= endY + thickness; k++){
|
||||
pixels.set(n, k, 0, color[0]);
|
||||
pixels.set(n, k, 1, color[1]);
|
||||
pixels.set(n, k, 2, color[2]);
|
||||
//pixels.set(n, k, 3, color[3]);
|
||||
|
||||
pixelSetter(n, k, [color[0], color[1], color[2]], pixels); //to remove 4th channel - pixels.set(n, k, 3, color[3]);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
// Define kernels for the sobel filter
|
||||
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
const kernelx = [
|
||||
[-1, 0, 1],
|
||||
[-2, 0, 2],
|
||||
@@ -41,19 +43,14 @@ module.exports = function(pixels, highThresholdRatio, lowThresholdRatio, useHyst
|
||||
return pixels;
|
||||
};
|
||||
|
||||
|
||||
function supress(pixels, pixel) {
|
||||
pixels.set(pixel[0], pixel[1], 0, 0);
|
||||
pixels.set(pixel[0], pixel[1], 1, 0);
|
||||
pixels.set(pixel[0], pixel[1], 2, 0);
|
||||
pixels.set(pixel[0], pixel[1], 3, 255);
|
||||
pixelSetter(pixel[0], pixel[1], [0, 0, 0, 255], pixels);
|
||||
|
||||
}
|
||||
|
||||
function preserve(pixels, pixel) {
|
||||
pixels.set(pixel[0], pixel[1], 0, 255);
|
||||
pixels.set(pixel[0], pixel[1], 1, 255);
|
||||
pixels.set(pixel[0], pixel[1], 2, 255);
|
||||
pixels.set(pixel[0], pixel[1], 3, 255);
|
||||
pixelSetter(pixel[0], pixel[1], [255, 255, 255, 255], pixels);
|
||||
|
||||
}
|
||||
|
||||
// sobelFilter function that convolves sobel kernel over every pixel
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
module.exports = function flipImage(oldPixels, pixels, axis) {
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
var width = oldPixels.shape[0],
|
||||
height = oldPixels.shape[1];
|
||||
|
||||
function copyPixel(x1, y1, x2, y2){
|
||||
pixels.set(x1, y1, 0, oldPixels.get(x2, y2, 0));
|
||||
pixels.set(x1, y1, 1, oldPixels.get(x2, y2, 1));
|
||||
pixels.set(x1, y1, 2, oldPixels.get(x2, y2, 2));
|
||||
pixels.set(x1, y1, 3, oldPixels.get(x2, y2, 3));
|
||||
pixelSetter(x1, y1, [oldPixels.get(x2, y2, 0), oldPixels.get(x2, y2, 1), oldPixels.get(x2, y2, 2), oldPixels.get(x2, y2, 3)], pixels);
|
||||
|
||||
}
|
||||
|
||||
function flip(){
|
||||
|
||||
@@ -10,8 +10,7 @@ module.exports = function Gamma(options, UI) {
|
||||
var step = this;
|
||||
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json')),
|
||||
adjustment = options.adjustment || defaults.adjustment;
|
||||
var val = adjustment / defaults.adjustment;
|
||||
val = options.adjustment || defaults.adjustment;
|
||||
|
||||
function changePixel(r, g, b, a) {
|
||||
|
||||
|
||||
@@ -5,9 +5,10 @@
|
||||
"adjustment": {
|
||||
"type": "float",
|
||||
"desc": "gamma correction (inverse of actual gamma factor) for the new image",
|
||||
"default": 0.2,
|
||||
"min": 2,
|
||||
"max": 1
|
||||
"default": 0.5,
|
||||
"min": 0,
|
||||
"max": 5,
|
||||
"step": 0.1
|
||||
}
|
||||
},
|
||||
"docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md#gamma-correction-module"
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
module.exports = function Invert(options, UI) {
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
var output;
|
||||
|
||||
// The function which is called on every draw.
|
||||
function draw(input, callback, progressObj) {
|
||||
function draw(input, callback) {
|
||||
|
||||
var getPixels = require('get-pixels');
|
||||
var savePixels = require('save-pixels');
|
||||
|
||||
@@ -21,10 +23,8 @@ module.exports = function Invert(options, UI) {
|
||||
for (var i = 0; i < pixels.shape[0]; i++) {
|
||||
for (var j = 0; j < pixels.shape[1]; j++) {
|
||||
let val = (i / width) * 255;
|
||||
pixels.set(i, j, 0, val);
|
||||
pixels.set(i, j, 1, val);
|
||||
pixels.set(i, j, 2, val);
|
||||
pixels.set(i, j, 3, 255);
|
||||
pixelSetter(i, j, [val, val, val, 255], pixels);
|
||||
|
||||
}
|
||||
}
|
||||
var chunks = [];
|
||||
|
||||
@@ -1,27 +1,31 @@
|
||||
module.exports = exports = function(pixels, options){
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
options.x = Number(options.x) || defaults.x;
|
||||
options.y = Number(options.y) || defaults.y;
|
||||
if(Number(options.x) == 0){
|
||||
options.x = 1;
|
||||
}
|
||||
if( Number(options.y) == 0) {
|
||||
options.y = 1;
|
||||
}
|
||||
|
||||
options.x = Math.abs(Number(options.x)) || defaults.x;
|
||||
options.y = Math.abs(Number(options.y)) || defaults.y;
|
||||
color = options.color || defaults.color;
|
||||
color = color.substring(color.indexOf('(') + 1, color.length - 1); // extract only the values from rgba(_,_,_,_)
|
||||
color = color.split(',');
|
||||
|
||||
for(var x = 0; x < pixels.shape[0]; x += options.x){
|
||||
for(var y = 0 ; y < pixels.shape[1]; y++){
|
||||
pixels.set(x, y, 0, color[0]);
|
||||
pixels.set(x, y, 1, color[1]);
|
||||
pixels.set(x, y, 2, color[2]);
|
||||
//pixels.set(x, y, 3, color[3]);
|
||||
pixelSetter(x, y, [color[0], color[1], color[2]], pixels); // to remove 4th channel - pixels.set(x, y, 3, color[3]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
for(var y = 0; y < pixels.shape[1]; y += options.y){
|
||||
for(var x = 0 ; x < pixels.shape[0]; x++){
|
||||
pixels.set(x, y, 0, color[0]);
|
||||
pixels.set(x, y, 1, color[1]);
|
||||
pixels.set(x, y, 2, color[2]);
|
||||
//pixels.set(x, y, 3, color[3]);
|
||||
pixelSetter(x, y, [color[0], color[1], color[2]], pixels); // to remove 4th channel - pixels.set(x, y, 3, color[3]);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,9 @@ module.exports = function Channel(options, UI) {
|
||||
|
||||
function draw(input, callback, progressObj) {
|
||||
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
const defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
options.gradient = options.gradient || defaults.gradient;
|
||||
options.gradient = JSON.parse(options.gradient);
|
||||
|
||||
@@ -32,10 +34,8 @@ module.exports = function Channel(options, UI) {
|
||||
|
||||
for (let x = 0; x < 256; x++) {
|
||||
for (let y = 0; y < 256; y++) {
|
||||
pixels.set(x, y, 0, 255);
|
||||
pixels.set(x, y, 1, 255);
|
||||
pixels.set(x, y, 2, 255);
|
||||
pixels.set(x, y, 3, 255);
|
||||
pixelSetter(x, y, [255, 255, 255, 255], pixels);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,9 +43,8 @@ module.exports = function Channel(options, UI) {
|
||||
if (options.gradient) {
|
||||
for (let x = 0; x < 256; x++) {
|
||||
for (let y = 0; y < 10; y++) {
|
||||
pixels.set(x, 255 - y, 0, x);
|
||||
pixels.set(x, 255 - y, 1, x);
|
||||
pixels.set(x, 255 - y, 2, x);
|
||||
pixelSetter(x, 255 - y, [x, x, x], pixels);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -56,9 +55,8 @@ module.exports = function Channel(options, UI) {
|
||||
let pixCount = Math.round(convfactor * hist[x]);
|
||||
|
||||
for (let y = startY; y < pixCount; y++) {
|
||||
pixels.set(x, 255 - y, 0, 204);
|
||||
pixels.set(x, 255 - y, 1, 255);
|
||||
pixels.set(x, 255 - y, 2, 153);
|
||||
pixelSetter(x, 255 - y, [204, 255, 153], pixels);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
102
src/modules/MinifyImage/Module.js
Normal file
102
src/modules/MinifyImage/Module.js
Normal file
@@ -0,0 +1,102 @@
|
||||
module.exports = function MinifyImage(options, UI) {
|
||||
var output;
|
||||
if (!options.inBrowser) {
|
||||
base64Img = require('base64-img');
|
||||
imagemin = require('imagemin');
|
||||
imageminJpegtran = require('imagemin-jpegtran');
|
||||
imageminPngquant = require('imagemin-pngquant');
|
||||
}
|
||||
|
||||
function draw(input, callback, progressObj) {
|
||||
progressObj.stop(true);
|
||||
progressObj.overrideFlag = true;
|
||||
|
||||
var step = this;
|
||||
|
||||
function dataURItoBlob(dataURI) {
|
||||
// convert base64 to raw binary data held in a string
|
||||
// doesn't handle URLEncoded DataURIs - see SO answer #6850276 for code that does this
|
||||
var byteString = atob(dataURI.split(',')[1]);
|
||||
|
||||
// separate out the mime component
|
||||
var mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0];
|
||||
|
||||
// write the bytes of the string to an ArrayBuffer
|
||||
var ab = new ArrayBuffer(byteString.length);
|
||||
|
||||
// create a view into the buffer
|
||||
var ia = new Uint8Array(ab);
|
||||
|
||||
// set the bytes of the buffer to the correct values
|
||||
for (var i = 0; i < byteString.length; i++) {
|
||||
ia[i] = byteString.charCodeAt(i);
|
||||
}
|
||||
|
||||
// write the ArrayBuffer to a blob, and you're done
|
||||
var blob = new Blob([ab], {
|
||||
type: mimeString
|
||||
});
|
||||
return blob;
|
||||
|
||||
}
|
||||
if (options.inBrowser) {
|
||||
var Compressor = require('compressorjs');
|
||||
var blob = dataURItoBlob(input.src);
|
||||
new Compressor(blob, {
|
||||
quality: options.quality || 0.5,
|
||||
success(result) {
|
||||
var reader = new FileReader();
|
||||
reader.readAsDataURL(result);
|
||||
reader.onloadend = function () {
|
||||
base64data = reader.result;
|
||||
output(base64data, input.format);
|
||||
if (callback) callback();
|
||||
return;
|
||||
};
|
||||
|
||||
},
|
||||
error(err) {
|
||||
console.log(err.message);
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
else{
|
||||
let filePath = __dirname + '/images/';
|
||||
var returnPath = base64Img.imgSync(input.src, filePath, 'test');
|
||||
(async () => {
|
||||
const files = await imagemin([returnPath], {
|
||||
destination: __dirname + '/results/',
|
||||
plugins: [
|
||||
imageminJpegtran(),
|
||||
imageminPngquant({
|
||||
quality: [0.6, 0.8]
|
||||
})
|
||||
]
|
||||
});
|
||||
var destPath = __dirname + '/results/test.' + input.format;
|
||||
var data = base64Img.base64Sync(destPath);
|
||||
output(data, input.format);
|
||||
if (callback) callback();
|
||||
})();
|
||||
}
|
||||
|
||||
|
||||
function output(datauri, mimetype) {
|
||||
|
||||
// This output is accessible by Image Sequencer
|
||||
step.output = {
|
||||
src: datauri,
|
||||
format: mimetype
|
||||
};
|
||||
}
|
||||
}
|
||||
return {
|
||||
options: options,
|
||||
draw: draw,
|
||||
output: output,
|
||||
UI: UI
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
4
src/modules/MinifyImage/index.js
Normal file
4
src/modules/MinifyImage/index.js
Normal file
@@ -0,0 +1,4 @@
|
||||
module.exports = [
|
||||
require('./Module'),
|
||||
require('./info.json')
|
||||
];
|
||||
14
src/modules/MinifyImage/info.json
Normal file
14
src/modules/MinifyImage/info.json
Normal file
@@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "minify-image",
|
||||
"description": "Minifies the given image (Works for jpg/jpeg/webp images in browser)",
|
||||
"url": "https://github.com/publiclab/image-sequencer/tree/master/MODULES.md",
|
||||
"inputs": {
|
||||
"quality":{
|
||||
"type": "float",
|
||||
"desc": "quality aspect of the given image",
|
||||
"default": "0.5"
|
||||
}
|
||||
},
|
||||
"docs-link":"https://github.com/publiclab/image-sequencer/blob/main/docs/MODULES.md#add-qr-module"
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ module.exports = function Noise(pixels, method) {
|
||||
|
||||
for(let y = 0; y < pixels.shape[1]; y++){
|
||||
for(let x = 0; x < pixels.shape[0]; x++){
|
||||
let i = 0, k = 0, windowr = [],windowg = [], windowb = [];
|
||||
let i = 0, k = 0, windowr = [], windowg = [], windowb = [];
|
||||
|
||||
while( k <= 8){
|
||||
let newX = x + neighbourX[k], newY = y + neighbourY[k];
|
||||
@@ -14,9 +14,9 @@ module.exports = function Noise(pixels, method) {
|
||||
if( newX >= 0 && newX < pixels.shape[0])
|
||||
{
|
||||
if( newY >= 0 && newY < pixels.shape[1]){
|
||||
windowr[i] = pixels.get((newX),(newY),0);
|
||||
windowg[i] = pixels.get((newX),(newY),1);
|
||||
windowb[i] = pixels.get((newX),(newY),2);
|
||||
windowr[i] = pixels.get((newX), (newY), 0);
|
||||
windowg[i] = pixels.get((newX), (newY), 1);
|
||||
windowb[i] = pixels.get((newX), (newY), 2);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
@@ -27,22 +27,22 @@ module.exports = function Noise(pixels, method) {
|
||||
windowg.sort();
|
||||
windowb.sort();
|
||||
|
||||
if(i%2 == 0)
|
||||
if(i % 2 == 0)
|
||||
{
|
||||
let value = windowr[i/2] + windowr[(i/2)-1];
|
||||
pixels.set(x,y,0,value);
|
||||
let value = windowr[i / 2] + windowr[(i / 2) - 1];
|
||||
pixels.set(x, y, 0, value);
|
||||
|
||||
value = windowg[i/2] + windowg[(i/2)-1];
|
||||
pixels.set(x,y,1,value);
|
||||
value = windowg[i / 2] + windowg[(i / 2) - 1];
|
||||
pixels.set(x, y, 1, value);
|
||||
|
||||
value = windowb[i/2] + windowb[(i/2)-1];
|
||||
pixels.set(x,y,2,value);
|
||||
value = windowb[i / 2] + windowb[(i / 2) - 1];
|
||||
pixels.set(x, y, 2, value);
|
||||
|
||||
}
|
||||
else {
|
||||
pixels.set(x, y, 0, windowr[Math.floor(i/2)]);
|
||||
pixels.set(x, y, 1, windowg[Math.floor(i/2)]);
|
||||
pixels.set(x, y, 2, windowb[Math.floor(i/2)]);
|
||||
pixels.set(x, y, 0, windowr[Math.floor(i / 2)]);
|
||||
pixels.set(x, y, 1, windowg[Math.floor(i / 2)]);
|
||||
pixels.set(x, y, 2, windowb[Math.floor(i / 2)]);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -52,7 +52,7 @@ module.exports = function Noise(pixels, method) {
|
||||
|
||||
for(let y = 0; y < pixels.shape[1]; y++){
|
||||
for(let x = 0; x < pixels.shape[0]; x++){
|
||||
let i = 0, k = 0, sumR=0, sumG = 0, sumB =0;
|
||||
let i = 0, k = 0, sumR = 0, sumG = 0, sumB = 0;
|
||||
|
||||
while( k <= 8){
|
||||
let newX = x + neighbourX[k], newY = y + neighbourY[k];
|
||||
@@ -60,18 +60,18 @@ module.exports = function Noise(pixels, method) {
|
||||
if( newX >= 0 && newX < pixels.shape[0])
|
||||
{
|
||||
if( newY >= 0 && newY < pixels.shape[1]){
|
||||
sumR += pixels.get(newX,newY,0);
|
||||
sumG += pixels.get(newX,newY,1);
|
||||
sumB += pixels.get(newX,newY,2);
|
||||
sumR += pixels.get(newX, newY, 0);
|
||||
sumG += pixels.get(newX, newY, 1);
|
||||
sumB += pixels.get(newX, newY, 2);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
k++;
|
||||
}
|
||||
|
||||
pixels.set(x, y, 0, sumR/i);
|
||||
pixels.set(x, y, 1, sumG/i);
|
||||
pixels.set(x, y, 2, sumB/i);
|
||||
pixels.set(x, y, 0, sumR / i);
|
||||
pixels.set(x, y, 1, sumG / i);
|
||||
pixels.set(x, y, 2, sumB / i);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ module.exports = exports = function(pixels, options) {
|
||||
|
||||
|
||||
let defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
let fillColor = options.fillColor || defaults.fillColor,
|
||||
x = parseInt(options.startingX) || defaults.startingX,
|
||||
@@ -47,10 +48,8 @@ module.exports = exports = function(pixels, options) {
|
||||
} while (isSimilar(currx, south) && south < height);
|
||||
|
||||
for (n = north + 1; n < south; n += 1) {
|
||||
pixels.set(currx, n, 0, fillColor[0]);
|
||||
pixels.set(currx, n, 1, fillColor[1]);
|
||||
pixels.set(currx, n, 2, fillColor[2]);
|
||||
pixels.set(currx, n, 3, fillColor[3]);
|
||||
pixelSetter(currx, n, fillColor, pixels);
|
||||
|
||||
if (isSimilar(currx - 1, n)) {
|
||||
queuex.push(currx - 1);
|
||||
queuey.push(n);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
module.exports = exports = function(pixels, options){
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
var color = options.color || 'rgb(228,86,81)';
|
||||
color = color.substring(color.indexOf('(') + 1, color.length - 1); // extract only the values from rgba(_,_,_,_)
|
||||
|
||||
@@ -23,7 +25,6 @@ module.exports = exports = function(pixels, options){
|
||||
g >= cg * minFactor && g <= cg * maxFactor &&
|
||||
b >= cb * minFactor && b <= cb * maxFactor);
|
||||
}
|
||||
|
||||
for(var i = 0; i < pixels.shape[0]; i++){
|
||||
for(var j = 0; j < pixels.shape[1]; j++){
|
||||
var r = pixels.get(i, j, 0),
|
||||
@@ -32,16 +33,16 @@ module.exports = exports = function(pixels, options){
|
||||
if(isSimilar(r, g, b)){
|
||||
if (replaceMethod == 'greyscale'){
|
||||
var avg = (r + g + b) / 3;
|
||||
pixels.set(i, j, 0, avg);
|
||||
pixels.set(i, j, 1, avg);
|
||||
pixels.set(i, j, 2, avg);
|
||||
pixelSetter(i, j, [avg, avg, avg], pixels);
|
||||
|
||||
}else {
|
||||
pixels.set(i, j, 0, replaceColor[0]);
|
||||
pixels.set(i, j, 1, replaceColor[1]);
|
||||
pixels.set(i, j, 2, replaceColor[2]);
|
||||
pixelSetter(i, j, replaceColor, pixels);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return pixels;
|
||||
};
|
||||
@@ -23,20 +23,17 @@ module.exports = function Rotate(options, UI) {
|
||||
|
||||
function extraManipulation(pixels) {
|
||||
var rotate_value = (options.rotate) % 360;
|
||||
|
||||
if (rotate_value % 360 == 0)
|
||||
return pixels;
|
||||
|
||||
var bitmap = new imagejs.Bitmap({ width: pixels.shape[0], height: pixels.shape[1] });
|
||||
bitmap._data.data = pixels.data;
|
||||
|
||||
var rotated = bitmap.rotate({
|
||||
degrees: rotate_value,
|
||||
});
|
||||
pixels.data = rotated._data.data;
|
||||
|
||||
var radians = (Math.PI) * rotate_value / 180;
|
||||
var width = pixels.shape[0];
|
||||
var height = pixels.shape[1];
|
||||
var cos = Math.cos(radians);
|
||||
var sin = Math.sin(radians);
|
||||
//final dimensions after rotation
|
||||
var pixels2 = require('ndarray')(new Uint8Array(4 * (Math.floor(Math.abs(width * cos) + Math.abs(height * sin) + 5) * (Math.floor(Math.abs(width * sin) + Math.abs(height * cos)) + 5))).fill(0), [Math.floor(Math.abs(width * cos) + Math.abs(height * sin)) + 5, Math.floor(Math.abs(width * sin) + Math.abs(height * cos)) + 4, 4]);
|
||||
pixels = require('./Rotate')(pixels, pixels2, options, rotate_value, width, height, cos, sin);
|
||||
return pixels;
|
||||
}
|
||||
|
||||
|
||||
function output(image, datauri, mimetype) {
|
||||
// This output is accesible by Image Sequencer
|
||||
|
||||
38
src/modules/Rotate/Rotate.js
Normal file
38
src/modules/Rotate/Rotate.js
Normal file
@@ -0,0 +1,38 @@
|
||||
module.exports = function Rotate(pixels, pixels2, options, rotate_value, width, height, cos, sin){
|
||||
var imagejs = require('imagejs');
|
||||
var height_half = Math.floor(height / 2);
|
||||
var width_half = Math.floor(width / 2);
|
||||
var dimension = width + height;
|
||||
|
||||
if (rotate_value % 360 == 0)
|
||||
return pixels;
|
||||
function copyPixel(x1, y1, x2, y2,pixel_set,pixel_get){
|
||||
pixel_set.set(x1, y1, 0, pixel_get.get(x2, y2, 0));
|
||||
pixel_set.set(x1, y1, 1, pixel_get.get(x2, y2, 1));
|
||||
pixel_set.set(x1, y1, 2, pixel_get.get(x2, y2, 2));
|
||||
pixel_set.set(x1, y1, 3, pixel_get.get(x2, y2, 3));
|
||||
}
|
||||
|
||||
pixels1 = require('ndarray')(new Uint8Array(4 * dimension * dimension).fill(0), [dimension, dimension, 4]);
|
||||
//copying all the pixels from image to pixels1
|
||||
for (var n = 0; n < pixels.shape[0]; n++){
|
||||
for (var m = 0; m < pixels.shape[1]; m++){
|
||||
copyPixel(n + height_half, m + width_half, n, m,pixels1,pixels);
|
||||
}
|
||||
}
|
||||
//rotating pixels1
|
||||
var bitmap = new imagejs.Bitmap({ width: pixels1.shape[0], height: pixels1.shape[1] });
|
||||
bitmap._data.data = pixels1.data;
|
||||
|
||||
var rotated = bitmap.rotate({
|
||||
degrees: rotate_value,
|
||||
});
|
||||
pixels1.data = rotated._data.data;
|
||||
//cropping extra whitespace
|
||||
for (var n = 0; n < pixels2.shape[0]; n++){
|
||||
for (var m = 0; m < pixels2.shape[1]; m++){
|
||||
copyPixel(n, m, n + Math.floor(dimension / 2 - Math.abs(width * cos / 2) - Math.abs(height * sin / 2)) - 1, m + Math.floor(dimension / 2 - Math.abs(height * cos / 2) - Math.abs(width * sin / 2)) - 1,pixels2,pixels1);
|
||||
}
|
||||
}
|
||||
return pixels2;
|
||||
};
|
||||
@@ -3,44 +3,36 @@ module.exports = function TextOverlay(options, UI) {
|
||||
|
||||
var output;
|
||||
|
||||
function draw(input, callback, progressObj) {
|
||||
|
||||
progressObj.stop(true);
|
||||
progressObj.overrideFlag = true;
|
||||
function draw(input, callback) {
|
||||
|
||||
var step = this;
|
||||
if (!options.step.inBrowser) { // This module is only for browser
|
||||
this.output = input;
|
||||
callback();
|
||||
|
||||
var priorStep = this.getStep(-1); // get the previous step to add text onto it.
|
||||
|
||||
function extraManipulation(pixels) {
|
||||
//if (options.step.inBrowser)
|
||||
pixels = require('./TextOverlay')(pixels, options, priorStep);
|
||||
return pixels;
|
||||
}
|
||||
else {
|
||||
var priorStep = this.getStep(-1); // get the previous step to add text onto it.
|
||||
|
||||
function extraManipulation(pixels) {
|
||||
//if (options.step.inBrowser)
|
||||
pixels = require('./TextOverlay')(pixels, options, priorStep);
|
||||
return pixels;
|
||||
}
|
||||
function output(image, datauri, mimetype) {
|
||||
|
||||
function output(image, datauri, mimetype) {
|
||||
|
||||
// This output is accesible by Image Sequencer
|
||||
step.output = { src: datauri, format: mimetype };
|
||||
|
||||
}
|
||||
|
||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||
output: output,
|
||||
ui: options.step.ui,
|
||||
extraManipulation: extraManipulation,
|
||||
format: input.format,
|
||||
image: options.image,
|
||||
inBrowser: options.inBrowser,
|
||||
callback: callback,
|
||||
useWasm:options.useWasm
|
||||
});
|
||||
// This output is accesible by Image Sequencer
|
||||
step.output = { src: datauri, format: mimetype };
|
||||
|
||||
}
|
||||
|
||||
return require('../_nomodule/PixelManipulation.js')(input, {
|
||||
output: output,
|
||||
ui: options.step.ui,
|
||||
extraManipulation: extraManipulation,
|
||||
format: input.format,
|
||||
image: options.image,
|
||||
inBrowser: options.inBrowser,
|
||||
callback: callback,
|
||||
useWasm:options.useWasm
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
module.exports = exports = function(pixels, options, priorstep){
|
||||
|
||||
var $ = require('jquery'); // to make text-overlay work for node.js
|
||||
|
||||
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
|
||||
|
||||
options.text = options.text || defaults.text;
|
||||
|
||||
@@ -40,6 +40,5 @@
|
||||
"desc": "Enter the font size in pixels.",
|
||||
"default": "12"
|
||||
}
|
||||
},
|
||||
"only": "browser"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,9 @@
|
||||
module.exports = function PixelManipulation(image, options) {
|
||||
// To handle the case where pixelmanipulation is called on the input object itself
|
||||
// like input.pixelManipulation(options)
|
||||
|
||||
const pixelSetter = require('../../util/pixelSetter.js');
|
||||
|
||||
if (arguments.length <= 1) {
|
||||
options = image;
|
||||
image = this;
|
||||
@@ -86,10 +89,8 @@ module.exports = function PixelManipulation(image, options) {
|
||||
y
|
||||
);
|
||||
|
||||
pixels.set(x, y, 0, pixel[0]);
|
||||
pixels.set(x, y, 1, pixel[1]);
|
||||
pixels.set(x, y, 2, pixel[2]);
|
||||
pixels.set(x, y, 3, pixel[3]);
|
||||
pixelSetter(x, y, pixel, pixels);
|
||||
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
10
src/util/getImageDimensions.js
Normal file
10
src/util/getImageDimensions.js
Normal file
@@ -0,0 +1,10 @@
|
||||
module.exports = function getImageDimensions(img, cb) {
|
||||
var getPixels = require('get-pixels');
|
||||
var dimensions = { width: '', height: '' };
|
||||
getPixels(img, function(err, pixels) {
|
||||
dimensions.width = pixels.shape[0];
|
||||
dimensions.height = pixels.shape[1];
|
||||
cb(dimensions);
|
||||
});
|
||||
};
|
||||
|
||||
5
src/util/pixelSetter.js
Normal file
5
src/util/pixelSetter.js
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = function(x, y, value, pixels){
|
||||
for(let i = 0; i < value.length; i++){
|
||||
pixels.set(x, y, i, value[i]);
|
||||
}
|
||||
};
|
||||
32
test/core/modules/minify-image.js
Normal file
32
test/core/modules/minify-image.js
Normal file
@@ -0,0 +1,32 @@
|
||||
const dataURI = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQAQMAAAAlPW0iAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABlBMVEX+AAD///+KQee0AAAAAWJLR0QB/wIt3gAAAAd0SU1FB+EGHRIVAvrm6EMAAAAMSURBVAjXY2AgDQAAADAAAceqhY4AAAAldEVYdGRhdGU6Y3JlYXRlADIwMTctMDYtMjlUMTg6MjE6MDIrMDI6MDDGD83DAAAAJXRFWHRkYXRlOm1vZGlmeQAyMDE3LTA2LTI5VDE4OjIxOjAyKzAyOjAwt1J1fwAAAABJRU5ErkJggg==';
|
||||
console.log(dataURI);
|
||||
const ImageSequencer = require('../../../src/ImageSequencer');
|
||||
const test = require('tape');
|
||||
var atob = require('atob');
|
||||
|
||||
var sequencer = ImageSequencer();
|
||||
var base64str = dataURI.substr(22);
|
||||
var decoded = atob(base64str);
|
||||
|
||||
|
||||
var initialSize = decoded.length;
|
||||
|
||||
|
||||
sequencer.loadImage(dataURI, function(){
|
||||
this.addSteps('minify-image');
|
||||
});
|
||||
|
||||
|
||||
test('minify-image minifies the image', t => {
|
||||
sequencer.run(function callback(out){
|
||||
console.log(out);
|
||||
var base64str = out.substr(22);
|
||||
var decoded = atob(base64str);
|
||||
var miniifiedSize = decoded.length;
|
||||
var isLess = miniifiedSize < initialSize;
|
||||
t.equal(isLess, true, 'image minified');
|
||||
t.end();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
describe('Default sequencer HTML', function() {
|
||||
|
||||
var DefaultHtmlSequencerUi = require('../../examples/lib/defaultHtmlSequencerUi');
|
||||
var sequencer = require('../../src/ImageSequencer')();
|
||||
var defaultHtmlSequencerUi;
|
||||
|
||||
beforeEach(()=>{
|
||||
defaultHtmlSequencerUi = new DefaultHtmlSequencerUi(sequencer);
|
||||
|
||||
spyOn(defaultHtmlSequencerUi, 'onLoad');
|
||||
spyOn(defaultHtmlSequencerUi, 'selectNewStepUi');
|
||||
spyOn(defaultHtmlSequencerUi, 'removeStepUi');
|
||||
spyOn(defaultHtmlSequencerUi, 'addStepUi');
|
||||
spyOn(defaultHtmlSequencerUi, 'importStepsFromUrlHash');
|
||||
|
||||
defaultHtmlSequencerUi.onLoad();
|
||||
defaultHtmlSequencerUi.selectNewStepUi();
|
||||
defaultHtmlSequencerUi.addStepUi();
|
||||
defaultHtmlSequencerUi.removeStepUi();
|
||||
defaultHtmlSequencerUi.importStepsFromUrlHash();
|
||||
});
|
||||
|
||||
it('load default ui', function() {
|
||||
expect(defaultHtmlSequencerUi.onLoad).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('select step ui', function() {
|
||||
expect(defaultHtmlSequencerUi.selectNewStepUi).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('add step ui', function() {
|
||||
expect(defaultHtmlSequencerUi.addStepUi).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('remove step ui', function() {
|
||||
expect(defaultHtmlSequencerUi.removeStepUi).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('import options from url', function() {
|
||||
expect(defaultHtmlSequencerUi.importStepsFromUrlHash).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -1,61 +0,0 @@
|
||||
var { JSDOM } = require('jsdom');
|
||||
var DOM = new JSDOM('<body></body>');
|
||||
|
||||
global.document = DOM.window.document;
|
||||
|
||||
describe('Sequencer step HTML', function() {
|
||||
|
||||
var DefaultHtmlStepUi = require('../../examples/lib/defaultHtmlStepUi');
|
||||
var sequencer = require('../../src/ImageSequencer')();
|
||||
var defaultHtmlStepUi;
|
||||
var step = 'brightness';
|
||||
var options = {
|
||||
name: 'Brightness',
|
||||
description: 'Change the brightness of the image by given percent value'
|
||||
};
|
||||
// options = JSON.parse(options)
|
||||
|
||||
beforeEach(()=>{
|
||||
defaultHtmlStepUi = new DefaultHtmlStepUi(sequencer);
|
||||
|
||||
spyOn(defaultHtmlStepUi, 'getPreview');
|
||||
spyOn(defaultHtmlStepUi, 'onSetup');
|
||||
spyOn(defaultHtmlStepUi, 'onComplete');
|
||||
spyOn(defaultHtmlStepUi, 'onDraw');
|
||||
spyOn(defaultHtmlStepUi, 'onRemove');
|
||||
spyOn(defaultHtmlStepUi, 'notify');
|
||||
|
||||
defaultHtmlStepUi.getPreview();
|
||||
defaultHtmlStepUi.onSetup(step, options);
|
||||
defaultHtmlStepUi.onComplete(step);
|
||||
defaultHtmlStepUi.onDraw(step);
|
||||
defaultHtmlStepUi.onRemove(step);
|
||||
defaultHtmlStepUi.notify('Step removed', 'remove-notification');
|
||||
});
|
||||
|
||||
|
||||
it('result preview ui', function() {
|
||||
expect(defaultHtmlStepUi.getPreview).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('load initial setup ui', function() {
|
||||
expect(defaultHtmlStepUi.onSetup).toHaveBeenCalledWith(step, options);
|
||||
});
|
||||
|
||||
it('load completion ui', function() {
|
||||
expect(defaultHtmlStepUi.onComplete).toHaveBeenCalledWith(step);
|
||||
});
|
||||
|
||||
it('draw step ui', function() {
|
||||
expect(defaultHtmlStepUi.onDraw).toHaveBeenCalledWith(step);
|
||||
});
|
||||
|
||||
it('remove step ui', function() {
|
||||
expect(defaultHtmlStepUi.onRemove).toHaveBeenCalledWith(step);
|
||||
});
|
||||
|
||||
it('notification ui', function() {
|
||||
expect(defaultHtmlStepUi.notify).toHaveBeenCalledWith('Step removed', 'remove-notification');
|
||||
});
|
||||
|
||||
});
|
||||
@@ -1,8 +0,0 @@
|
||||
var SpecReporter = require('jasmine-spec-reporter').SpecReporter;
|
||||
|
||||
jasmine.getEnv().clearReporters(); // remove default reporter logs
|
||||
jasmine.getEnv().addReporter(new SpecReporter({ // add jasmine-spec-reporter
|
||||
spec: {
|
||||
displayPending: true
|
||||
}
|
||||
}));
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('Default sequencer HTML', function() {
|
||||
|
||||
var DefaultHtmlSequencerUi = require('../examples/lib/defaultHtmlSequencerUi');
|
||||
var sequencer = require('../src/ImageSequencer')();
|
||||
var DefaultHtmlSequencerUi = require('../../../examples/lib/defaultHtmlSequencerUi');
|
||||
var sequencer = require('../../../src/ImageSequencer')();
|
||||
var defaultHtmlSequencerUi;
|
||||
|
||||
beforeEach(()=>{
|
||||
@@ -39,4 +39,12 @@ describe('Default sequencer HTML', function() {
|
||||
it('import options from url', function() {
|
||||
expect(defaultHtmlSequencerUi.importStepsFromUrlHash).toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
xit('adds a step from the quick selector', function() {
|
||||
expect($('.step').length).toBe(1);
|
||||
$("[data-value='brightness']").click()
|
||||
expect($('.step').length).toBe(2);
|
||||
// expect($('.step:last img'))[0].src).not.toEqualTo($('.step:first img'));
|
||||
// TODO: test the actual `src` attribute of $('.step:last img') against a known value
|
||||
});
|
||||
});
|
||||
@@ -5,8 +5,8 @@ global.document = DOM.window.document;
|
||||
|
||||
describe('Sequencer step HTML', function() {
|
||||
|
||||
var DefaultHtmlStepUi = require('../examples/lib/defaultHtmlStepUi');
|
||||
var sequencer = require('../src/ImageSequencer')();
|
||||
var DefaultHtmlStepUi = require('../../../examples/lib/defaultHtmlStepUi');
|
||||
var sequencer = require('../../../src/ImageSequencer')();
|
||||
var defaultHtmlStepUi;
|
||||
var step = 'brightness';
|
||||
var options = {
|
||||
@@ -15,6 +15,16 @@ describe('Sequencer step HTML', function() {
|
||||
};
|
||||
// options = JSON.parse(options)
|
||||
|
||||
beforeAll(() => {
|
||||
const { JSDOM } = require('jsdom');
|
||||
var { window } = new JSDOM();
|
||||
|
||||
const { document } = window;
|
||||
global.window = window;
|
||||
global.document = document;
|
||||
const $ = global.jQuery = global.$ = require('jquery');
|
||||
});
|
||||
|
||||
beforeEach(()=>{
|
||||
defaultHtmlStepUi = new DefaultHtmlStepUi(sequencer);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('Preview UI HTML', function() {
|
||||
|
||||
var InsertPreview = require('../../examples/lib/insertPreview');
|
||||
var sequencer = require('../../src/ImageSequencer')();
|
||||
var InsertPreview = require('../../../examples/lib/insertPreview');
|
||||
var sequencer = require('../../../src/ImageSequencer')();
|
||||
var insertPreview;
|
||||
var options = { brightness: 50 };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
describe('Intermediate step HTML', function() {
|
||||
|
||||
var IntermediateHtmlStepUi = require('../../examples/lib/intermediateHtmlStepUi');
|
||||
var sequencer = require('../../src/ImageSequencer')();
|
||||
var IntermediateHtmlStepUi = require('../../../examples/lib/intermediateHtmlStepUi');
|
||||
var sequencer = require('../../../src/ImageSequencer')();
|
||||
var intermediateHtmlStepUi;
|
||||
|
||||
beforeEach(()=>{
|
||||
24
test/ui/spec/mapHtmlTypes.spec.js
Normal file
24
test/ui/spec/mapHtmlTypes.spec.js
Normal file
@@ -0,0 +1,24 @@
|
||||
describe('HTML Types Mapping Function', function() {
|
||||
|
||||
var mapHtmlTypes = require('../../../examples/lib/mapHtmltypes');
|
||||
|
||||
it('maps range and number types', function() {
|
||||
expect(mapHtmlTypes({type: 'percentage'})).toEqual({type: 'number'});
|
||||
|
||||
expect(mapHtmlTypes({type: 'integer'})).toEqual({type: 'number'});
|
||||
expect(mapHtmlTypes({type: 'integer', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100});
|
||||
|
||||
expect(mapHtmlTypes({type: 'float'})).toEqual({type: 'text'});
|
||||
expect(mapHtmlTypes({type: 'float', min: 20, max: 100})).toEqual({type: 'range', min: 20, max: 100});
|
||||
});
|
||||
|
||||
it('maps text type', function() {
|
||||
expect(mapHtmlTypes({type: 'string'})).toEqual({type: 'text'});
|
||||
expect(mapHtmlTypes({type: 'anything'})).toEqual({type: 'text'});
|
||||
});
|
||||
|
||||
it('maps select type', function() {
|
||||
expect(mapHtmlTypes({type: 'select'})).toEqual({type: 'select'});
|
||||
});
|
||||
|
||||
});
|
||||
81
test/ui/spec/scopeQuery.spec.js
Normal file
81
test/ui/spec/scopeQuery.spec.js
Normal file
@@ -0,0 +1,81 @@
|
||||
const scopeQuery = require('../../../examples/lib/scopeQuery');
|
||||
|
||||
describe('scopeQuery Method', function() {
|
||||
|
||||
beforeAll(() => {
|
||||
const { JSDOM } = require('jsdom');
|
||||
|
||||
var { window } = new JSDOM(`
|
||||
<body>
|
||||
<div id="scope1">
|
||||
<div class="child" id="child1">Child1</div>
|
||||
<div class="child" id="child2">Child2</div>
|
||||
<div class="child" id="child3">Child3</div>
|
||||
<div class="child" id="child4">Child4</div>
|
||||
<div class="child" id="child5">Child5</div>
|
||||
<div class="child" id="child6">Child6</div>
|
||||
</div>
|
||||
|
||||
<div id="scope2">
|
||||
<div class="child" id="child1">Child1Scope2</div>
|
||||
<div class="child" id="child2">Child2Scope2</div>
|
||||
<div class="child" id="child3">Child3Scope2</div>
|
||||
<div class="child" id="child4">Child4Scope2</div>
|
||||
<div class="child" id="child5">Child5Scope2</div>
|
||||
</div>
|
||||
</body>`);
|
||||
|
||||
const { document } = window;
|
||||
global.window = window;
|
||||
global.document = document;
|
||||
const $ = global.jQuery = global.$ = require('jquery');
|
||||
});
|
||||
|
||||
|
||||
it('scope 1 querySelector', function() {
|
||||
|
||||
const $scope1 = scopeQuery.scopeSelector(document.querySelector('#scope1'));
|
||||
const $scope1All = scopeQuery.scopeSelectorAll(document.querySelector('#scope1'));
|
||||
|
||||
expect($scope1('.child').length).toBe(1);
|
||||
expect($scope1All('.child').length).toBe(6);
|
||||
|
||||
expect($scope1('#child1').text()).toBe('Child1');
|
||||
expect($scope1('#child2').text()).toBe('Child2');
|
||||
|
||||
expect($scope1All('#child1').text()).toBe('Child1');
|
||||
expect($scope1All('#child2').text()).toBe('Child2');
|
||||
|
||||
expect($scope1().elem('.child').length).toBe(1);
|
||||
expect($scope1().elemAll('.child').length).toBe(6);
|
||||
|
||||
expect($scope1All().elem('.child').length).toBe(1);
|
||||
expect($scope1All().elemAll('.child').length).toBe(6);
|
||||
});
|
||||
|
||||
it('scope 2 querySelector', function() {
|
||||
|
||||
const $scope2 = scopeQuery.scopeSelector(document.querySelector('#scope2'));
|
||||
const $scope2All = scopeQuery.scopeSelectorAll(document.querySelector('#scope2'));
|
||||
|
||||
expect($scope2('.child').length).toBe(1);
|
||||
expect($scope2All('.child').length).toBe(5);
|
||||
|
||||
expect($scope2('#child1').text()).toBe('Child1Scope2');
|
||||
expect($scope2('#child2').text()).toBe('Child2Scope2');
|
||||
|
||||
expect($scope2All('#child1').text()).toBe('Child1Scope2');
|
||||
expect($scope2All('#child2').text()).toBe('Child2Scope2');
|
||||
|
||||
expect($scope2().elem('.child').length).toBe(1);
|
||||
expect($scope2().elemAll('.child').length).toBe(5);
|
||||
|
||||
expect($scope2All().elem('.child').length).toBe(1);
|
||||
expect($scope2All().elemAll('.child').length).toBe(5);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
global.document = null;
|
||||
global.$ = null;
|
||||
DOM = null;
|
||||
@@ -1,6 +1,6 @@
|
||||
describe('URL manipulation methods', function() {
|
||||
|
||||
var UrlHash = require('../../examples/lib/urlHash');
|
||||
var UrlHash = require('../../../examples/lib/urlHash');
|
||||
var urlHash;
|
||||
var params = {
|
||||
module: 'brightness',
|
||||
Reference in New Issue
Block a user