niel, your previous script not takes results bigger than four numbers at color and in final result takes repeating colors. can you say what needs to change?
on pix_val(x, y)
set JS to "sampleDoc();
function sampleDoc() {
var doc, sam, unts, x;
units = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
doc = app.activeDocument;
doc.colorSamplers.removeAll();
sam = doc.colorSamplers.add( [ " & x & ", " & y & " ] );
app.preferences.rulerUnits = units;
return parseInt(sam.color.rgb.red)+' '+parseInt(sam.color.rgb.green)+' '+parseInt(sam.color.rgb.blue);
};"
tell application "Adobe Photoshop CS4"
-- open your document here…
set col to do javascriptJS
return col
end tell
end pix_val
tell application "Adobe Photoshop CS4"
set y_max to height of current document
set x_max to width of current document
end tell
set yy to 0
set gt to ","
set val_list to {}
--set y_max to 5 -- вернуть потом значене к переменной
set rgb_col to {}
repeat y_max times
set xx to 0
repeat x_max times
set r_g_b to pix_val(xx, yy) --as text
set AppleScript'stext item delimiters to space
set rgb_col to rgb_col & xx & yy & r_g_b
--set val_list to val_list & {xx, yy, rgb_col}
set xx to xx + 1
end repeat
set yy to yy + 1
end repeat
set new_strings to {}
repeat with this_item from 3 to (countitems of rgb_col) by 3
set temp_list to {}
if itemthis_item of rgb_col is not in temp_list then set temp_list to temp_list & itemthis_item of rgb_col
repeat with this_list_item in items of temp_list
set new_strings to new_strings & (this_list_item as list)
end repeat
repeat with this_list from 1 to (countnew_strings)
if (itemthis_list of new_strings as string) is itemthis_item of rgb_col then
set itemthis_list of new_strings to {itemthis_list of new_strings} & items (this_item - 1) thru (this_item - 2) of rgb_col
end if
end repeat
end repeat
repeat with this_list_1 from 1 to (countitems of new_strings)
repeat with this_list_2 from (this_list_1 + 1) to (countitems of new_strings)
if itemthis_list_1 of new_strings is not {} and itemthis_list_2 of new_strings is not {} then
if item 1 of itemthis_list_1 of new_strings is item 1 of itemthis_list_2 of new_strings then
set itemthis_list_1 of new_strings to itemthis_list_1 of new_strings & (items 2 thru 3 of (get itemthis_list_2 of new_strings))
set itemthis_list_2 of new_strings to {}
exit repeat
end if
end if
end repeat
end repeat
set result_string to {}
repeat with this_string in new_strings
if rgb_col is not {} then set result_string to result_string & this_string
end repeat
result_string