Auto generate CMYK values from Lab?

gordo

Well-known member
Is there a way to automatically generate CMYK screen tint values from a list of (several hundred) L*a*b* values?

thx, gordo
 
See Argyll CMS. It's a great set of color-management command line tools (cross platform). I use it every day and prefer its flexibility to x-rite's strange software.

After installation, the workflow you can use with it is this:
1. Make sure your Lab values are formatted as a simple text file with rows of values separated by white space.
2. In a command line terminal, run the following: xicclu -v0 -fb -ia -s100 ICC_Profile.icc < input_file.txt > output_file.txt

Flag meanings: -v0 outputs only values (-v shows more info). -fb looks backward in the ICC profile (from Lab to CMYK). -ia returns absolute colorimetric values (use -ir if you want relative and -ip for perceptual). -s100 scales the resulting values from 0.0-1.0 to 0.0-100.0.
 
On a mac, the following AppleScript will ask you to choose a plain text (.txt) file with some lab values and then use Photoshop conversion engine to get the equivalent CMYK values, based on your Color Settings CMYK working space ICC profile and conversion options rendering intent. The source .txt file formatting is crucial (I haven't had the time to code it better to deal with various formatting) but if you follow the simple rules as per the script comments (and attached png to show .txt required formatting) it should work. Just paste the following code in AppleScript editor, then click "Compile" then "Run". Alternatively, you can save this as an AppleScript application and double-click on the app icon to run it. Hope it helps:

--make sure the appropriate CMYK working space and rendering intents are set in Photoshop "Color Settings" before running the script
tell application "Adobe Photoshop CS5.1"
activate
set my_report to "Lab = CMYK"
--rules for Lab value format .txt file
--make sure the file that contains lab values is of type plain text .txt
--one lab definition color per line such as 76 -5 10 then 91 12 -10 on the very next line and so on
--note that there is a space after the "L" value (but not before)and a space after the "a" value (but not after the "b" value)
--do not create empty lines in between lab values rows and do not press return after the "b" value of your last lab entry
set my_lab_text_file to (choose file with prompt "Choose the .txt file that contains the lab values")
set my_lab_entries to every paragraph of (read my_lab_text_file)
repeat with this_lab_value in my_lab_entries
set my_paragraph to ""
set AppleScript's text item delimiters to " "
set {l, a, b} to {text item 1 of this_lab_value, text item 2 of this_lab_value, text item 3 of this_lab_value}
set AppleScript's text item delimiters to {""}
set foreground color to {class:Lab color, value_L:l, value_a:a, value_b:b}
set a to foreground color
--get properties of a
set b to convert color a to CMYK
set c to round (cyan of b)
set m to round (magenta of b)
set y to round (yellow of b)
set k to round (black of b)
set my_paragraph to this_lab_value & " = " & c & space & m & space & y & space & k
set my_report to my_report & return & my_paragraph
end repeat
end tell
--generate and display final conversion report
tell application "Finder"
activate
set my_conversion_report to (path to the desktop as string) & "lab_to_cmyk.txt"
open for access file my_conversion_report with write permission
write my_report to file my_conversion_report
close access file my_conversion_report
open file my_conversion_report
end tell
 

Attachments

  • source lab plain text file.png
    source lab plain text file.png
    25 KB · Views: 201
  • result.png
    result.png
    22.2 KB · Views: 204
Last edited:

PressWise

A 30-day Fix for Managed Chaos

As any print professional knows, printing can be managed chaos. Software that solves multiple problems and provides measurable and monetizable value has a direct impact on the bottom-line.

“We reduced order entry costs by about 40%.” Significant savings in a shop that turns about 500 jobs a month.


Learn how…….

   
Back
Top