Using a script to match color with curves

Community Beginner ,
Mar 27, 2021 Mar 27, 2021

Copy link to clipboard

Copied

I am looking for a way to automatically match colors in a picture using curves adjustment layer.

In a post from 2014 on this forum I found a script by @jugenjury that is supposed to do exactly that. Unfortunately, a number of symbols turned into an emoji in the original post so the script "as is" is not usable. 

Capture.JPG

I figured, there must be a value for "i", but if I put (i>0) or ((i+1)>0) instead like so, and try to run the script, Photoshop ends up freezing.

function arrayComp(array1,array2) {

if (array1.length != array2.length) return false;

i=array1.length-1;

while (i>0) {

if (array1 != array2) return false;

i--;

}

return true;

...

Does anybody know where the problem might be?

I'll put the whole script in the first commentary below as it is quite long.

TOPICS
Actions and scripting, How to

Views

357

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct Answer

Adobe Community Professional , Mar 29, 2021 Mar 29, 2021
It seems to work. I did not particularly delve into it.

Likes

translate

Translate

Translate
Most Valuable Participant ,
Mar 28, 2021 Mar 28, 2021

Copy link to clipboard

Copied

Where is the script that a small segment of a script you need to download the full script. the statement was most likely 

 

while i;

 

for some reason you got a icon for the  "i;"

What you posted is  size an array top left bottom right of the document the  The function look to see if two arrays have the same length and the while sees if the element are the same.  However, I not see the  elements being selected using i as a index into the arrays.  the two [i] seem missing.  But I only hack at scripting I can be wrong.

JJMack

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 28, 2021 Mar 28, 2021

Copy link to clipboard

Copied

Thank you very much!

For some reason I can't post the whole script as a reply.  Just wouldn't go.

 

I just tried "i;" and got a syntax error...

 

The first part of the script looks like this:

 

#target Photoshop

 

var startRulerUnits = app.preferences.rulerUnits;

var startTypeUnits = app.preferences.typeUnits ;

var startDisplayDialogs = app.displayDialogs;

 

app.preferences.rulerUnits = Units.PIXELS;

app.preferences.typeUnits = TypeUnits.PIXELS;

app.displayDialogs = DialogModes.NO;

 

doc=app.activeDocument;

var colorRefin=new SolidColor;

var colorRefout=new SolidColor;

R=new Array;

G=new Array;

B=new Array;

var dialogMode=DialogModes.NO;

Avg=20;

 

size=[0+" px",0+" px",doc.width,doc.height];

function arrayComp(array1,array2) {

    if (array1.length != array2.length) return false;

    i=array1.length-1;

    while

Hmarachos_0-1616933397924.png

{

        if (array1 != array2) return false;

        i--;

    }

    return true;

}

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 28, 2021 Mar 28, 2021

Copy link to clipboard

Copied

@JJMack 

I'll upload the script as a .txt file here.

If you happen to have time, please have a look at it. 

The problem I am talking about is in line 39. Currently it's "while i; {"

 

Thank you!

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Most Valuable Participant ,
Mar 28, 2021 Mar 28, 2021

Copy link to clipboard

Copied

The while statement should be 

 

while (i) {

 

 

However the script seems to loop before the function is used,  I had to kill PS. 

 

here is hoe I changet the statemt.  I also added an alert in the beginning of the function when PS hung the see it it was caused bt the fubction.  However PS hung before the function was used.

 

image.png

JJMack

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 28, 2021 Mar 28, 2021

Copy link to clipboard

Copied

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 28, 2021 Mar 28, 2021

Copy link to clipboard

Copied

Yes, thank you! 

This is where I found the aforementioned script. 

The problem is, one symbol in it has turned into an emoji which makes the script unusable...

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Mar 29, 2021 Mar 29, 2021

Copy link to clipboard

Copied

It seems to work. I did not particularly delve into it.

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 29, 2021 Mar 29, 2021

Copy link to clipboard

Copied

Thank you very much!

It does seem to work!

Likes

translate

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines