RGBA decimal percentage conversion in Applescript

I’m trying to figure out how to convert the percentage colors below into the values beneath. When I divide out 50462/65535 for the alpha component the percentage returns as expected, but for the others there is something I’m missing. Any ideas of where I should be looking to find my answer?

{0.6029444336999999, 0.7743185759, 0.9406489730000001, 0.7700007558}

{35240, 47270, 60611, 50462}

Where are you getting those values? It sounds like color management is involved somewhere.

Exported from a Skim template using color.redComponent, color.greenComponent, etc.

But you posted two sets of numbers. Are they both from the same source?


I’m exporting notes from Skim with the template below, and in Applescript I’m getting the same value (see edit) from Skim with the Applescript below. I wish to export as a text file from Skim, so that I have more options when exporting, but I wish to manipulate with Applescript to export to other applications.

EDIT: Not getting same value, but rather I’m asking for the same color.


* <$type.typeName/>, page <$page.label?><$page.label/><?$page.label?><$pageIndex.numberByAddingOne/></$page.label?> {<$color.redComponent/>, <$color.greenComponent/>, <$color.blueComponent/>, <$color.alphaComponent/>}





tell application "Skim" to set the theColors to favorite colors
set favC1 to item 2 of theColors

not sure if this helps, but here are all the colors both from the template export and the applescript.

Template: {0, 0, 0, 0.1499961912631989}
Applescript: {0, 0, 0, 9830}

Template: {0.6029444336891174, 0.7743185758590698, 0.9406489729881287, 0.7700007557868958}
Applescript: {35240, 47270, 60611, 50462}

Template: {0.7888072729110718, 0.9657987952232361, 0.7536230087280273, 1}
Applescript: {49087, 63479, 46003, 65535}

Template: {0.947003185749054, 0.9161649942398071, 0.5638315081596375, 1}
Applescript: {61166, 59367, 32298, 65535}

Template: {0.9818622469902039, 0.8332256078720093, 0.9784092307090759, 1}
Applescript: {63736, 51400, 63736, 65535}

Template: {0.6925210356712341, 0.5290737152099609, 0.1552896201610565, 0.7700007557868958}
Applescript: {41163, 30040, 7841, 50462}

I’m afraid the only explanation I can see is that Skim is doing something wrong, or trying to do some kind of color correction – perhaps mapping to the nearest colours in a fixed pallet. A cursory glance at their dictionary in Script Debugger’s Explorer shows the conversions there seem OK. I think you’re going to have to contact the developer.


Are you perhaps confusing ‘favorite colors’ with note colors?

tell application "Skim" to set theColors to color of notes of document 1

the favorite colors are the colors of document 1 (because thats all that I use), but thanks for the try

tell application "Skim" to set theColors to color of notes of document 1


{{0, 0, 0, 9830}, {35240, 47270, 60611, 50462}, {49087, 63479, 46003, 65535}, {61166, 59367, 32298, 65535}, {63736, 51400, 63736, 65535}, {41163, 30040, 7841, 50462}}

DrLulz, since the value for transparency seems to be correct, isn’t it a question of some filter applied to the color values (I would say typically a color profile). Can you make changes regarding any color profile to your image or your color values? Or can you somehow convert the colors to HSL or Lab?

Normally color profiles are only used for your screen, not for files. But if that’s the case it would mean that the developer(s) of skim return an screen color in AppleScript and the original (document) color in the file or vice versa. That problem would easily be found when color profile is set off or change in system preferences or application. The differences in coloring should be noticed in either AppleScript or the file.

Can I accomplish this with Applescript, so then when I attempt to match up color values (within the Applescript) I’m able to do so?

Yes, only when AppleScript is the cause of the problem. Then when changing color profile between runs of your script and the values of the colors will change as well you have found the problem.

I don’t know Skim so consider me as an ignorant :slight_smile: but here is some litterature about AS and Skim: SourceForge.

I was also wondering if the difference though unexpected would make a great mismatch at the end of day. Some slight differences in color values are often just not visible. (I think up to 5% make no real difference for our eyes.) But well.