• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Extract Colour Codes Quickly

New Here ,
Jul 16, 2024 Jul 16, 2024

Copy link to clipboard

Copied

Is there a way to extract HEX, RGB and CMYK colour codes quickly instead of copying and pasting each individually? Is there a way to select the colour and for Adobe to provide the codes at once? I have a large number of colours I need to do this for in a brand guidelines document I have created for a client.

 

Thank you in advance 🙂

TOPICS
How to

Views

810

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 2 Correct answers

Community Expert , Jul 17, 2024 Jul 17, 2024

Hi @Sophie Hooper , Also, for branding color you have to consider the affect of color profiles on RGB and CMYK color—the appearance of any RGB or CMYK value will change depending on the profile assignment. Using a device independant color space like Lab (Pantone Solid ink colors) as the source color for the brand is the best approach—this post might help:

 

https://community.adobe.com/t5/indesign-discussions/branding-color-guide/td-p/10818696

 

 

Votes

Translate

Translate
Participant , Jul 18, 2024 Jul 18, 2024

To use the script you will need to copy the text above into a new blank file by launching the Script Editor app. Don't let the dumb quote marks get smartened because that will cause the script to fail to compile — should be fine if you just copy from your browser to Script Editor. Compile the script  by clicking on the hammer icon and it should look like this. 

 

SE.png

 

Open your InDesign file and then click the black triangle to run the script. 

 

You should then have the list of colors on your clipboard

...

Votes

Translate

Translate
Participant ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

If you are using a Mac this AppleScript will put a tab-delimited list, derived from the active InDesign document, onto your clipboard. It ignores the first four built-in InDesign swatches.

 

If you are on a PC I'm sure someone could do the same in JavaScript.

 

 

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set TextOut to ""
set AppleScript's text item delimiters to {", "}
tell application id "com.adobe.InDesign"
	tell document 1
		set ES to (every swatch)
		repeat with s from 5 to count of items of ES
			tell item s of ES
				set SN to name
				set SM to model
				set SS to space
				set SV to color value
				set TextOut to TextOut & return & SN & "		" & SM & "		" & SS & "	{" & SV & "}"
			end tell
		end repeat
	end tell
end tell

set the clipboard to TextOut

 

Votes

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
New Here ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

Thank you for this! I'm new to working with scripts in Adobe - sorry for the silly question, but how do I add and use this in InDesign? I'm on a Mac. 

Votes

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
Participant ,
Jul 18, 2024 Jul 18, 2024

Copy link to clipboard

Copied

To use the script you will need to copy the text above into a new blank file by launching the Script Editor app. Don't let the dumb quote marks get smartened because that will cause the script to fail to compile — should be fine if you just copy from your browser to Script Editor. Compile the script  by clicking on the hammer icon and it should look like this. 

 

SE.png

 

Open your InDesign file and then click the black triangle to run the script. 

 

You should then have the list of colors on your clipboard.

 

If it does what you want, save the script file and put it in "Macintosh HD:Applications:Adobe InDesign XXXX:Scripts:Scripts Panel" so that you can run it from inside InDesign. 

 

You could add this line to the end of the script to confirm that the list has been created.

 

display dialog TextOut buttons {"OK"} default button "OK" giving up after 10

 

This script is very simple (crude) and has no error trapping for, for instance, there being no InDesign file open, but it won't do any harm.

 

InDesign's scriptability is amazingly powerful by the way!

 

Hope that helps.

Votes

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
New Here ,
Sep 23, 2024 Sep 23, 2024

Copy link to clipboard

Copied

This script only gives me CMYK values for some colours and RGB values for other colours. Is there a script that will give all values for every swatch in the document?

Votes

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
Participant ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

The script returns CMYK values for swatches whose Colour Mode is CMYK and RGB values for swatches whose Colour Mode is RGB.  Is what you want to have both values for all Swatches whatever their Colour Mode is set to?

 

I can't see a way to ask InDesign what the RGB value would be for a CMYK swatch and vice versa but I suppose it could be temporarily changed and then changed back. There is HSB and Lab as well of course, would you want those values too?

 

Perhaps that would help to know what do you want to do with the list.

 

 

Votes

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
Participant ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

Here's a not very sophisticated way to get all the values. The figures are rounded down because InDesign reports them to 12 decimal places. 

It puts a tab delimited list that can be copied into a spreadsheet onto the clipboard.

 

use AppleScript version "2.4" -- Yosemite (10.10) or later
use scripting additions

set TextOut to ("Name" & tab & "RGB" & tab & "CMYK" & tab & "LAB" & tab & "HSB" & return)
set AppleScript's text item delimiters to {", "}
tell application id "com.adobe.InDesign"
	tell document 1
		set ES to (every swatch)
		repeat with s from 5 to count of items of ES
			tell item s of ES
				set HoldSpace to space
				set SN to name
				set TextOut to TextOut & SN & tab
				set space to RGB
				set SV to color value
				set SV to (RoundFigures(SV) of me)
				set TextOut to TextOut & SV & tab
				set space to CMYK
				set SV to color value
				set SV to (RoundFigures(SV) of me)
				set TextOut to TextOut & SV & tab
				set space to LAB
				set SV to color value
				set SV to (RoundFigures(SV) of me)
				set TextOut to TextOut & SV & tab
				set space to HSB
				set SV to color value
				set SV to (RoundFigures(SV) of me)
				set TextOut to TextOut & SV & return
				set space to HoldSpace
			end tell
		end repeat
	end tell
end tell

set the clipboard to TextOut

on RoundFigures(v)
	repeat with n from 1 to count of items of v
		set x to (item n of v)
		set x to round x
		set item n of v to x
	end repeat
	return v
end RoundFigures

 

Votes

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 Expert ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

@Nick Passmore

 

Won't switching between spaces - change original values?

 

I think working on a temporary copy of the swatch would be safer? 

 

Votes

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 Expert ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

I think working on a temporary copy of the swatch would be safer? 

 

Yes, and there is still the document profiles problem-- the returned values are going to be different depending on the profile assignments.

Votes

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
Participant ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

Good point, a copy of the whole document would probably be best.

Votes

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 Expert ,
Sep 24, 2024 Sep 24, 2024

Copy link to clipboard

Copied

a copy of the whole document would probably be best.

 

The values are still going to be dependent on what ever the document color profile assignments happen to be when the script is run.

 

Consider this Blue CMYK Swatch with starting values of 100|20|5|5, but in documents with different profile assignments—none of these values would be particularly useful for defining brand colors:

 

Screen Shot.pngScreen Shot 1.png

Votes

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 Expert ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

Hi @Sophie Hooper , Also, for branding color you have to consider the affect of color profiles on RGB and CMYK color—the appearance of any RGB or CMYK value will change depending on the profile assignment. Using a device independant color space like Lab (Pantone Solid ink colors) as the source color for the brand is the best approach—this post might help:

 

https://community.adobe.com/t5/indesign-discussions/branding-color-guide/td-p/10818696

 

 

Votes

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
New Here ,
Jul 17, 2024 Jul 17, 2024

Copy link to clipboard

Copied

Thank you for this 🙂

Votes

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
New Here ,
Oct 26, 2024 Oct 26, 2024

Copy link to clipboard

Copied

LATEST

for me it didn't work. The script said "the space is write protected"

any idea how to fix this?

thank you ver much in advance!

Votes

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