Customize Eyedropper/ Color Picker

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

Ray
Posts: 7
Joined: Tue Aug 09, 2016 9:27 am

Customize Eyedropper/ Color Picker

Post by Ray »

Hi,
I'm new in photoshop scripting.
I want want to convert any selected color inside the Color Picker dialog to a custom color space.
I would like to convert the eyedropper picked colors to the same color space.
I know how to convert colors but i don't know how to script this in photoshop.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Customize Eyedropper/ Color Picker

Post by Kukurykus »

Maybe I can do this, but can't promise my current scripting abilities let me for that. Firstly explain me what is custom (same) color space in Ps.
Is that I can find in (Image / Mode or View / Proof Setup) ? Please show to me how would you convert it manually (step by step if possible), so I'll see I can script it...
Ray
Posts: 7
Joined: Tue Aug 09, 2016 9:27 am

Re: Customize Eyedropper/ Color Picker

Post by Ray »

Hello,
thanks for helping me.

What i would like exactly, is a script that auto convert any color selected with color picker or eyedropper into an other color using only those values:

0,8,16,24,33,41,49,57,66,74,82,90,99,107,115,123,132,140,148,156,165,173,181,189,198,206,214,222,231,239,247,255.

For example if i select the color (R14,G125,B232) i would like the script to automatically change the color into (R16,G123,B231).
If i select the color (R254,G4,B9) i would like the script to automatically change the color into (R255,G0,B8).

Does it mean any sense?
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Customize Eyedropper/ Color Picker

Post by Kukurykus »

Yes it's very easy. I want to say I can do it, and as I'm learning programming that is for me another little challange. I shouldn't have problem to script it like probably many other scripters from this site, but the difference is it can take me longer time than them, however I should make it for today / tomorrow.

- still I don't know what is that custom space in Photoshop?

- if you use color picker on some pixel do you want, that taken colour was automaticlly changed to that with new values or only taken to memory for later use? If that has to be automaticly changed then probably you'll have to press additionall key, right after picking (or I think up it better).

- do you want taken value (r/g/b) colour go to the nearest value you mentioned, or else nearest up or nearest down value? For ex. if there is picked value of colour with value 4, then there are the same range to 0 value and 8 value. Which value to it should be then converted, 0 or 8?
Last edited by Kukurykus on Tue Aug 09, 2016 6:04 pm, edited 1 time in total.
Ray
Posts: 7
Joined: Tue Aug 09, 2016 9:27 am

Re: Customize Eyedropper/ Color Picker

Post by Ray »

- this custom space is supposed to be 5 bits by channel.

- I would like if possible the taken colour automatically and instantly changed without pushing any button.

- I want the nearest value, if there is picked colour with value 4 then it should be converted into 0.
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Customize Eyedropper/ Color Picker

Post by Kukurykus »

Okey, now I understand what is custom colour space, and how you want to use it.

Maybe I'll combine it with other script in some part I created yestarday if I figure out it maye be helpful somehow:
https://www.ps-scripts.com/viewtopic.ph ... 33#p152333

As to quisetion there won't be be need to press something for convertion I can't guarantee, but when I made main part of script I'm sure someone from here can script or advice how to make automatical conversion (right after picking with nothing else).


So for now that's my last answer, I'll be back when I'll have something to share...
Ray
Posts: 7
Joined: Tue Aug 09, 2016 9:27 am

Re: Customize Eyedropper/ Color Picker

Post by Ray »

Okay thanks.
Does anyone know how to detect color selection Event ?
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Customize Eyedropper/ Color Picker

Post by Kukurykus »

It's tested in CS2 and CS5.1 and ready to use. I nested both notifier and color convertor in one .jsx file.

Anyeone else who wants to use it:

1) drop it to your Only Events Scripts in your Scripts folder you find in Presets of your Photoshop directory
2) Launch Photoshop and in the File / Scripts click Script Events Manager
3) Tick 'Enable Events to Run Scripts/Actions"
4) Dot 'Script' radio button, and choose 'Start Application' in 'Photoshop Event'
5) Click 'Add' and 'Done'
6) Quit and launch Photoshop


Now everytime you use a eyedropper on the oppened image, that colour of pixel you clicked will be automatically converted from RGB color space to 32x32x32 color range.

Code: Select all

#target photoshop

if (!(not = File((pth = path + '/Presets/Scripts/Event Scripts Only/Color Space Convertion.') + 'txt')).exists) {
notifiersEnabled = true; notifiers.add('setd', File(pth + 'jsx')); not.open('w'), not.write(), not.close()
}

for(i = 0, a = []; i < 256; i += 8) {
!(a.length % 4) ? (a.push(r = (!i ? i : i + 1)), i != r ? i++ : null) : a.push(i)
}
for(j = 0; j < (col = ['red', 'green', 'blue']).length; j++) {
for(k = 0; k < a.length; k++) {
if ((d2 = a[k]) - (eval((function rgb() {return R = 'foregroundColor.rgb.' + col[j]})())) > 0) {
eval(R + ' - (d1 = a[k - 1]) < 5 ? ' + R + '= d1 : ' + R + '= d2'); break
}
}
}

EDIT

Out of idle curiosity: where have you found values of that 5 bits RGB color space as I'd like to visit the site with and read more about... i.e. 0,8,16,24,33,41,49,57,66,74,82,90,99,107,115,123,132,140,148,156,165,173,181,189,198,206,214,222,231,239,247,255
Attachments
Color Space Convertion.zip
(729 Bytes) Downloaded 394 times
Ray
Posts: 7
Joined: Tue Aug 09, 2016 9:27 am

Re: Customize Eyedropper/ Color Picker

Post by Ray »

Hi,
First thanks a lot for your help.
I have found the colors in color table on wikipedia: https://en.wikipedia.org/wiki/List_of_m ... B_palettes
User avatar
Kukurykus
Posts: 528
Joined: Mon Jul 25, 2016 12:36 pm

Re: Customize Eyedropper/ Color Picker

Post by Kukurykus »

Maybe I can write some scripts but my knowledge about colours is still small. Can you tell me how you knew exact values of:
0,8,16,24,33,41,49,57,66,74,82,90,99,107,115,123,132,140,148,156,165,173,181,189,198,206,214,222,231,239,247,255
I can't find there on Wikipedia it. Maybe it's obvious for some people or maybe you used some mathematics forumla to result it?
I'm asking because this array has every 5 number growed by 1, so I want to know where exactly that is wrote it should look like it...
I only see it was used in Amiga.

PS In that code I implemented writing of .txt file in Only Events Scripts folder by first time of launching script. That was wrong as now you have each time to manually delete this file together with removing a script from Action Manager. So at the end placing it in two separate files is better option.