Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

grid of thumbnails showing step options in addStep ui #247

Closed
jywarren opened this issue May 5, 2018 · 24 comments
Closed

grid of thumbnails showing step options in addStep ui #247

jywarren opened this issue May 5, 2018 · 24 comments

Comments

@jywarren
Copy link
Member

jywarren commented May 5, 2018

We could generate a tiny thumbnail of the final image and run 5 or so of the most popular or useful modules, showing very low res previews of what they'd look like. Sort of like in Instagram!

(Low priority but fun, also dependent on a scale module)

@jywarren
Copy link
Member Author

jywarren commented May 5, 2018

screenshot_20180504-224813

@jonxuxu
Copy link
Member

jonxuxu commented Nov 22, 2018

This would be a cool task to work on for GCI! I'm happy to work on it if it will be made into one :)

@jywarren
Copy link
Member Author

This could be done as an alternative tab to the current "icons" ui approach. Or maybe you could think of another way it could be implemented! Perhaps so as not to have to auto-generate all the thumbnails unless you really want to?

Creating a GCI task now!

@jywarren
Copy link
Member Author

@jonxuxu
Copy link
Member

jonxuxu commented Nov 26, 2018

Thanks for the speedy response! I'm thinking of replacing the icons with this, with a crop overlay above the image for a crop preview. So which adjustments would you like previews for?

@jywarren
Copy link
Member Author

jywarren commented Nov 27, 2018 via email

@jonxuxu
Copy link
Member

jonxuxu commented Nov 27, 2018

I've never really worked with the image-sequencer ui before, though it is well documented. I made a new previewSequencer object in demo.js and set a custom ui for it, like so:

  var previewSequencer = ImageSequencer();

  // UI for the preview sequencer:
  previewSequencer.setUI({
    onSetup: function(step){
      // Create new property "step.image"
      step.image = document.createElement('img');
      if($("#" + step).length() > 0){
        $("#" + step).append(step.image);
        console.log(step + " element exists");
      } else {
        console.log(step + " element does not exist");
      }
    },
    onComplete: function(step){
      // Access predefined "step.output" and user-defined "step.image"
      step.image.src = step.output;
    },
    onRemove: function(step){
      // Access user-defined "step.image"
      step.image.remove();
    }
  });

Am I going in the right direction? Not really sure how to call the ui for a saturation layer for example and load the image in a div. I don't know if I should do that at all 😅

@jywarren
Copy link
Member Author

Hm, so I think rather than building a UI, you could make new images outside -- so something like this:

function generatePreview(element, steps) {
  function insertImage(src) {
    var img = document.createElement('img');
    img.src = src;
    $(element).append(img); // maybe append img to the element passed in as a parameter?
  }
  var previewSequencer = ImageSequencer();
  previewSequencer.loadImage(step_image_src)
                               .addSteps('resize:{x: 100, y: 100},' + steps)
                               .run(insertImage);
}

What do you think? This is probably not exactly right, but a decent start...

@jonxuxu
Copy link
Member

jonxuxu commented Nov 30, 2018

Hey, thanks so much for the clarification. I've created the function as outlined, but I'm not sure how to get images from the sequencer and pass it to the insertImage function.

// find any `src` parameters in URL hash and attempt to source image from them and run the sequencer
imageSource = "images/tulips.png";
if (getUrlHashParameter('src')) {
imageSource = getUrlHashParameter('src');
}
sequencer.loadImage(imageSource, ui.onLoad);
//Inserting previews
function generatePreview(element, source, filter, steps) {
function insertImage(src) {
var img = document.createElement('img');
img.src = src;
$(element).append(img); // maybe append img to the element passed in as a parameter?
}
var previewSequencer = new ImageSequencer();
previewSequencer.loadImage(source).addSteps(filter + "," + steps).run(insertImage);
}
generatePreview("#saturation", imageSource, "resize:{x: 100, y: 100}", 1);

It might be related, but I'm also getting errors on that line of code:
image

@jywarren
Copy link
Member Author

jywarren commented Nov 30, 2018 via email

@jonxuxu
Copy link
Member

jonxuxu commented Dec 1, 2018

Yeah I think getting a much more formalized way to get sequencer output would be much appreciated.

Here's my error when I use $('.step:last img')[0].src
image

Here's the error when I use previewSequencer.images.image1.steps[0].output.src
image

Logically, I think it should work. I've pushed my revisions to this branch.

@jonxuxu
Copy link
Member

jonxuxu commented Dec 2, 2018

@jywarren @publiclab/reviewers Sorry I have 6 hours left on this task.. I've had to abandon it temporarily while waiting so it wouldn't expire.

@jonxuxu
Copy link
Member

jonxuxu commented Dec 4, 2018

What's interesting to note is that the images object does exist:

image

However, it is printed after the error on line 47, which is technically above it. So I'm thinking this may be due to the fact that the function to load the object starts running before it has completely loaded? I'm not sure if that's the case, but I'll look into ways of waiting to run the function until after the object has completely loaded.

@jywarren
Copy link
Member Author

jywarren commented Dec 4, 2018 via email

@jonxuxu
Copy link
Member

jonxuxu commented Dec 4, 2018

No worries, you've got a lot on your plate! Good night.

@kevinzluo
Copy link

kevinzluo commented Dec 4, 2018

Hi @JonathanXu1
Since you've claimed this task for GCI, would you mind letting me take a shot at this one? I can't guarantee I can even get half as far as you did, but this seems really interesting and I'd like to try.

Thanks,
Kevin Luo

@jywarren
Copy link
Member Author

jywarren commented Dec 4, 2018

Hmm, maybe @kevinzluo could help move this along... in any case whoever takes it on please work collaboratively! #504

@jywarren
Copy link
Member Author

jywarren commented Dec 4, 2018

I think this has to do with asynchronous events, and we may have to execute the steps that are throwing an error in a callback, which Image Sequencer allows for on some of it's methods (see docs). So, the callback is a passed function which would run once the sequencer is done...

Are you working off the latest code in #504 ?

@kevinzluo
Copy link

Hi!

I haven't had a chance to really look at the code until this morning, and my initial idea is a bit different from what @JonathanXu1 is suggesting. Should I open up a new PR?

Also, could you please approve my task here (https://codein.withgoogle.com/dashboard/task-instances/5423277104168960/) so that I may go ahead and start working on this one?

Thanks!

@jonxuxu
Copy link
Member

jonxuxu commented Dec 4, 2018

Yeah I'm working off the latest code. I was thinking of doing a callback as well, but wasn't sure where the documentation for that was. Moreover, this issue also happens if I try to retrieve the values from the original sequencer.

@jywarren
Copy link
Member Author

jywarren commented Dec 4, 2018 via email

@jonxuxu
Copy link
Member

jonxuxu commented Dec 5, 2018

Yep, I'll push again to make sure.

@okonek okonek mentioned this issue Dec 6, 2018
4 tasks
@okonek
Copy link

okonek commented Dec 6, 2018

@jywarren Hi I've added that feature in this PR: #535 If I misunderstood your explanation or there is something to change in my solution, please let me know.
Thanks.

@jonxuxu
Copy link
Member

jonxuxu commented Dec 9, 2018

I've made pull request #539 that applies my changes on top of @okonek 's. @jywarren can merge both our forks, or @okonek can apply my changes to his fork.

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

No branches or pull requests

5 participants