AppleScript to convert CMYK to RGB values

A couple of days ago someone asked me if I knew how to convert CMYK to RGB using AppleScript. After boring them silly with my explanation of colour models and explaining that it’s not really possible, I came up with this which is a close approximation and finally gives me something to put on my blog.

on cmykrgb(c, m, y, k)

    set r to 255 - (round (2.55 * (c + k)))
    set g to 255 - (round (2.55 * (m + k)))
    set b to 255 - (round (2.55 * (y + k)))

    if (r < 0) then set r to 0
    if (g < 0) then set g to 0
    if (b < 0) then set b to 0

    return {r, g, b}
end cmykrgb

Posted under AppleScript

This post was written by stetho on June 12, 2008

Tags: , ,