# InDesign

5,514 posts
Jun 25, 2009
Currently Being Moderated

## Getting a greyscale value from the Eyedropper?

### Sep 21, 2011 7:40 PM

Tags:

Today, someone asked me how to pick up a gray value with the Eyedropper, and get a grayscale (K-only) color value in an otherwise CMYK document.

As we all know, the eyedropper tool gives RGB colorspace back, at least for raster images. So, fine, I get a gray rectangle with RGB:

Now, how can I convert this to grey? I can't really find a reasonable way. Converting to CMYK gives me 35/28/28/0, which is useles.

Converting to L*ab gives me 69/0/0, which seemed promising, but also is kind of a dead end:

In Illustrator, I have the choice for greyscale:

So, short of ducking over to Illustrator, is there a reasonable way to get the equivalent gray value out of InDesign?

I suppose one could write a script that uses math...but color math is hard, and it is easy to screw it up.

Of course, there is some amusing color science irony that if one tries to go the other way, say, from 39.0% K to RGB, one gets 169/171/174 . I suppose it relates to color profiles and whatnot (as does why Illustrator and InDesign may not end up with the same numbers).

Anyhow, any tips or convenient workarounds?

Sure would be nice if ID had "Grayscale" as an option like Illustrator...

Replies Previous Next
• Currently Being Moderated
Sep 22, 2011 5:17 AM   in reply to John Hawkinson

I generally just go to separations preview and read it...

|
Mark as:
• Currently Being Moderated
Sep 22, 2011 7:46 AM   in reply to John Hawkinson

Pick up the color and change to lab. The "l" value can be used, just invert it. (i.e. "l" reading is 22, gray equivalent would be 78)

|
Mark as:
• Currently Being Moderated
Sep 22, 2011 8:00 AM   in reply to John Hawkinson

John, after a few more tests, my suggested lab method is flawed.

|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 22, 2011 2:39 PM   in reply to John Hawkinson

Without a grayscale space there's no way to get a color managed  conversion to grayscale inside of ID.

With AppleScript I can go get the conversion from Photoshop. This takes the RGB fill of the current selection and gets the grayscale conversion in PS based on the current PS Color Settings:

activate

set {a, b, c} to color value of fill color of selection

set theColor to {class:RGB color, red:a, green:b, blue:c}

set gs to convert color theColor to grayscale

set k to gray value of gs

end tell

set properties of fill color of selection to {space:CMYK, color value:{0, 0, 0, k}}

display dialog "CMYK 0|0|0|" & k

end tell

Don't know if you can do something similar with JavaScript

edit: I added a line to update the selection fill with the converted CMYK color

|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 23, 2011 7:15 AM   in reply to John Hawkinson

This version keeps you in ID. It isn't a color managed conversion but comes close if your doc profile is SWOP:

set space of fill color of selection to LAB

set {a, b, c} to color value of fill color of selection

set myKvalue to (100 - a) * 1.15

if myKvalue is greater than 100 then

set myKvalue to 100

end if

set space of fill color of selection to CMYK

set color value of fill color of selection to {0, 0, 0, myKvalue}

end tell

|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 23, 2011 11:16 AM   in reply to John Hawkinson

For simplicity, etc., I really do like Peter's idea of using the Sep. Preview.

I missed Peter's post—sep preview does give you the file's exact gray value. For image files the eyedropper gives you correct values for Lab, CMYK, RGB images but not for grayscale because it doesn't exist. I've been wishing out loud for a grayscale space since ID2, but something tells me it won't happen. The missing grayscale space creates a number of display problems, but no output problems so it's probably not a priority.

1.15 is indeed a magic number. Reversing the L value gets you a linear tonal scale, so multiplying by some number imitates a curve—something like what you would get with Photoshop's 20% dot gain grayscale profile.

|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 24, 2011 6:08 AM   in reply to John Hawkinson

where does it come from?

Trial and error. As I mentioned in post 6 there's no CM here.

I was about to say a color managed conversion from neutral RGB colors to a black only CMYK is impossible, but remembered I use this profile to convert a grayscale image to black only CMYK and it will also work for neutral RGB:

http://www.zenodesign.com/forum/MaxBlack.zip

With the profile assigned to your doc, AdobeRGB 169|169|169 converts to 0|0|0|40.75—the same conversion you would get in PS converting from AdobeRGB to 20% Dot Gain grayscale.

So this simple script works:

set docprofile to CMYK profile of active document

set CMYK profile of active document to "MaxBlack"

set space of fill color of selection to CMYK

set CMYK profile of active document to docprofile

end tell

|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 24, 2011 7:26 AM   in reply to John Hawkinson

but actually I guess it's just a coincidence

Definitely a coincidence. If you are trying to find a K value that has the same appearance as a neutral RGB value there isn't a single constant that would get you there. If you change profiles the number wouldn't work and it probably doesn't work over the entire tonal scale anyway.

The maximum black profile trick does get you the correct conversion of RGB to Dot Gain 20% grayscale, but doesn't necessarily get you the same appearance because the black only CMYK color you get is previewed through your document's CMYK profile not a Dot Gain 20% grayscale profile. If your doc is all black/grayscale you could assign the MaxBlack profile and it would work. Otherwise Sep Preview is the way to go.

|
Mark as:
• Currently Being Moderated
Sep 24, 2011 7:36 AM   in reply to John Hawkinson

I'm not sure it really deserves a "correct" tag since it doesn't answer the question of how to use the eyedropper. It was really more of an observation than a suggested workaround.

|
Mark as:
• Currently Being Moderated
Sep 24, 2011 7:48 AM   in reply to John Hawkinson

Short debate. You win.

|
Mark as:
• Currently Being Moderated
Sep 25, 2011 2:45 PM   in reply to John Hawkinson

I'm a bit late to this party, but how's this?

var color = app.selection[0].fillColor;
if(color.space == ColorSpace.LAB||
color.space == ColorSpace.CMYK){
color.space = ColorSpace.RGB
}
if(color.space == ColorSpace.RGB){
var totalValue = color.colorValue[0] + color.colorValue[1] + color.colorValue[2];
var averageValue = totalValue/3;
color.colorValue = [averageValue,averageValue,averageValue];
}
var calcValue = 100 - (averageValue/255 * 100);
if(calcValue > 100){
calcValue = 100;
}
if(calcValue < 0){
calcValue = 0;
}

color.space = ColorSpace.CMYK;
color.colorValue = [0,0,0,calcValue];


|
Mark as:
• Currently Being Moderated
Sep 25, 2011 2:47 PM   in reply to John Hawkinson

I was tired when I wrote the script.

I fixed the code to what it should have been...

|
Mark as:
• Currently Being Moderated
Sep 25, 2011 2:54 PM   in reply to John Hawkinson

Well, any differences are InDesign's fault!

|
Mark as:
• Currently Being Moderated
Sep 25, 2011 3:07 PM   in reply to Harbs.

Harbs. wrote:

Well, any differences are InDesign's fault!

RGB black is much darker than 100K. Are you guys taking that into account?

|
Mark as:
• Currently Being Moderated
Sep 25, 2011 3:16 PM   in reply to Peter Spier

I think InDesign has dot gain in the calculations.

I'm trying to come up with an equation which will work to compensate across the spectrum...

This seems to work reasonably well when K is over 50%:

var fudgeFactor = -12;
var color = app.selection[0].fillColor;
if(color.space == ColorSpace.LAB||
color.space == ColorSpace.CMYK){
color.space = ColorSpace.RGB
}
if(color.space == ColorSpace.RGB){
var totalValue = color.colorValue[0] + color.colorValue[1] + color.colorValue[2];
var averageValue = totalValue/3;
}
var calcValue = 100 - (averageValue/255 * 100);
calcValue-=fudgeFactor;
if(calcValue > 100){
calcValue = 100;
}
if(calcValue < 0){
calcValue = 0;
}

var inverseValue = Math.abs(calcValue-100);
color.space = ColorSpace.CMYK;
color.colorValue = [0,0,0,calcValue];


|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 25, 2011 3:30 PM   in reply to John Hawkinson

If the aim really is to get the output K value there's no way.

Depending on what profiles are embedded the same original gray value can produce any number of RGB eyedropper values. So below is a doc with US Sheetfed Uncoated assigned with it's profile policy set to Preserve. The top PDF has no embedded profile (it gets the doc's profile). The bottom PDF has US SWOP Coated embedded and the profile is preserved. When I eyedropper the 40% patch from each image I get very different values 168|174|174 for the uncoated version, and 153|153|153 for the bottom version. In both images Sep Preview has the output as 0|0|0|40:

|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 25, 2011 3:28 PM   in reply to Harbs.

Grayscale image values are put on the black plate and output unchanged (ID ignores grayscale profiles). Their previews are adjusted by the assigned CMYK profile, which could be anything. Even if you could come up with an equation that converts the RGB to the output K value, it would only work for one profile.

|
Mark as:
• Currently Being Moderated
Sep 25, 2011 3:41 PM   in reply to Rob Day

Like Rob says, there's no perfect method, but this is pretty darn good:

var color = app.selection[0].fillColor;
if(color.space == ColorSpace.LAB||
color.space == ColorSpace.CMYK){
color.space = ColorSpace.RGB
}
if(color.space == ColorSpace.RGB){
var totalValue = color.colorValue[0] + color.colorValue[1] + color.colorValue[2];
var averageValue = totalValue/3;
}
var calcValue = 100 - (averageValue/255 * 100);
calcValue+=(calcValue/5.5);
if(calcValue > 100){
calcValue = 100;
}
if(calcValue < 0){
calcValue = 0;
}

var inverseValue = Math.abs(calcValue-100);
color.space = ColorSpace.CMYK;
color.colorValue = [0,0,0,calcValue];


|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 25, 2011 3:53 PM   in reply to Harbs.

When I ran it on my test the top returned 38, the bottom returned 47—not very useful in either case if you are looking for 40%

|
Mark as:
• Currently Being Moderated
Sep 25, 2011 3:55 PM   in reply to Harbs.

And dot gain is a non-linear curve. You get more at larger dot size and less at smaller sizes (well, up to a point -- at some point the dots will merge and they all become 100%).

|
Mark as:
• Currently Being Moderated
Sep 25, 2011 4:00 PM   in reply to Peter Spier

My equation is non-linear.

It's not perfect, but eyeballing various shades in InDesign seemed to give good results.

I wonder how good the Grayscale option in Illustrator is. Rob, do you care to run tests there?

|
Mark as:
• Currently Being Moderated
Sep 25, 2011 4:25 PM   in reply to Harbs.

Harbs. wrote:

My equation is non-linear.

I didn't look closely before, but I take it the non-linearity comes from this line:

calcValue+=(calcValue/5.5);

How did you arrive at 5.5

|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 25, 2011 4:59 PM   in reply to Harbs.

The results are the same out of Illustrator.

Remember the question here is can you get the grayscale output value from the eyedropper (the value that shows in Sep Preview)? ID doesn't apply any dot gain to grayscale images, the values go unchanged on to the black plate. When the grayscale is inside of a PDF and the PDF includes a CMYK profile the preview depends on the embedded CMYK profile, or the ID document CMYK profile if there's no profile included. You won't be able to come up with a working formula because the sampled RGB values are dependent on the assigned CMYK profile.

|
Mark as:
• Currently Being Moderated
Sep 25, 2011 10:08 PM   in reply to Peter Spier

Peter Spier wrote:

How did you arrive at 5.5

Trial and error...

|
Mark as:
• Currently Being Moderated
Sep 25, 2011 10:25 PM   in reply to Rob Day

rob day wrote:

The results are the same out of Illustrator.

Same as what? Same as each other (i.e. accurate), or similar to the results of my script (i.e. inaccurate)?

|
Mark as:
• Currently Being Moderated
Sep 26, 2011 5:14 AM   in reply to John Hawkinson

So why has nobody yet asked the obvious question?

If ID KNOWS the correct grayscale numbers (and CMYK numbers, for that matter, in CMYK images), which it clearly does in seps preview, WHY is it not possible to pick those up directly from placed rasters?

|
Mark as:
• Currently Being Moderated
Sep 26, 2011 5:36 AM   in reply to Peter Spier

Oh. I'm sure it's possible.

You interested in attempting to write a plugin to do this?

There's just very little exposed to scripting about placed images...

Harbs

|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 26, 2011 5:38 AM   in reply to Harbs.

In my post 23 test I placed the grayscale in ID and exported the page as PDF/X-1a (no profile) and then as PDF/X-4 (embed profiles). Then I placed both files in an ID doc with Preserve Embedded as the policy. The two placed PDFs have different RGB proxies even though the gray output values are identical. If I do the same out of Illustrator I get the same results.

Here's my test:

http://www.zenodesign.com/forum/gspdf.zip

|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 26, 2011 5:40 AM   in reply to Harbs.

Oh. I'm sure it's possible.

Not until ID has a grayscale space.

|
Mark as:
• Currently Being Moderated
Sep 26, 2011 5:46 AM   in reply to Rob Day

rob day wrote:

Not until ID has a grayscale space.

Well, it depends what you are expecting. Peter was asking why you can't get the values of the separations preview. I'm sure it's possible to get those values. If you want proper color-managed values, the yes, you are right it's not possible until InDesign supports gray profiles...

Harbs

|
Mark as:
• Currently Being Moderated
Sep 26, 2011 5:56 AM   in reply to Rob Day

My question was directed at the Grayscale option in the colors panel in Illustrator.

John was looking for the same functionality in InDesign.

I just tested, and the results of my script were superior to the results in Illustrator.

It looks like Illustrator just does a straight conversion of RGB values to K -- like my first attempt at my script.

The Grayscale option in Illustrator has no color adjustment whatsoever.

|
Mark as:
• 2,298 posts
Oct 16, 2007
Currently Being Moderated
Sep 26, 2011 6:17 AM   in reply to Peter Spier

WHY is it not possible to pick those up directly from placed rasters?

It does for CMYK and RGB images.

The eye dropper returns 100 Black when I sample a directly placed grayscale image. PDFs could have any number of color objects and embedded profiles, so I'm guessing that's why it's an RGB proxy.

Also, the eyedropper/PDF proxy relationship isn't reliable in anyway making a script impossible. It looks like the eyedropper picks up RGB values based on the color management setting when the PDF is placed, but the preview of an untagged PDF changes with the document's profile assignment. So below I've placed the PDF into a doc with US Sheetfed Uncoated assigned, switched the assignment to US Sheetfed Coated, sampled the 40% patch, and the RGB value isn't even close:

|
Mark as:
Previous Next
Actions

#### More Like This

• Retrieving data ...

#### Answers + Points = Status

• 10 points awarded for Correct Answers