Skip to main content
Inspiring
February 6, 2019
Answered

Eyedropper, picking a color from image

  • February 6, 2019
  • 2 replies
  • 855 views

I need to let my user pick a color from the image.

Ideally, with a tool he/she already knows how to use – eyedropper.

I can select eyedropper tool with a script, but I don't understand how can I get an event when color was picked?

This topic has been closed for replies.
Correct answer SuperMerlin

You could use the colorpicker...

var originalForeGroundColour = app.foregroundColor;

app.showColorPicker();

var selectedColour = app.foregroundColor;

alert(selectedColour.rgb.hexValue);

//reset foregroundColor to original colour

app.foregroundColor = originalForeGroundColour;

2 replies

SuperMerlin
SuperMerlinCorrect answer
Inspiring
February 6, 2019

You could use the colorpicker...

var originalForeGroundColour = app.foregroundColor;

app.showColorPicker();

var selectedColour = app.foregroundColor;

alert(selectedColour.rgb.hexValue);

//reset foregroundColor to original colour

app.foregroundColor = originalForeGroundColour;

AverinAAAAuthor
Inspiring
February 6, 2019

SuperMerlin​ That's actually a good idea, thanks, might be good enough.

Kukurykus Color Sampler has a bit non-intuitive UI for the user, eyedropper is used much more often. I consider color samplers to be somewhat internal, something I can use inside my implementation, but what user should never really see.

Also, forcing the user to click another button after picking a color is also not good UI

Kukurykus
Legend
February 6, 2019

Ah right I misunderstood you, but hmm it's not impossible to set event that sees when you use Color Picker, but problem is you had to combine your main script with the script that listen events, that is in other folder. There's also r-bin  method

Kukurykus
Legend
February 6, 2019

Use Color Sampler.

AverinAAAAuthor
Inspiring
February 6, 2019

Color sample looks quite bad from user perspective.

Also, I need only one color, not many.

I don't mind placing a colorSampler via script to where user clicked with eyedropper to grab the color. But, I still need to get an event when user clicks or drags somewhere with eyedropper

Kukurykus
Legend
February 6, 2019

If script activates Color Sampler Tool and user clicks on image, then after clicking another button on your extension that sampler is going to be removed, while color taken. The only Color Picker doesn't give you back the position.