Skip to main content
April 24, 2009
Answered

How to find out the grayscale percentage?

  • April 24, 2009
  • 3 replies
  • 5306 views

Is it possible to find out the grayscale percentage(k value) in "illustrator CS3" through scripting. Kindly advice me.

This topic has been closed for replies.
Correct answer DHounam

Thanks for your help. If i run the above code it throws an run time error(Error 21: undefined is not an object.) in the for statement block (4th line). Kindly advice me how to solve this.


That's right -- because, since I have no real idea what you're actually trying to do, tFrame is undefined in the snippet I posted.

You'll need to use the loop in context; specifically, as I stated, make tFrame refer to a block of text...

So if you select ONLY the block on the page, you can say:

tFrame = selection[0]

But that may not be how you want to proceed...

3 replies

May 4, 2009

mariaprabu wrote:

Is it possible to find out the grayscale percentage(k value) in "illustrator CS3" through scripting. Kindly advice me.

You'll need to be more specific. Yes scripting can tell you the color characteristics of vector artwork, but I'm sure if that's what you are asking.

shastafir

May 5, 2009

Through Scripting i can find out the color characteristics like cmyk and rgb percentages. But i could not know how to get the color characteristics of gray scale percentages. Kindly advice me.

Thanks

Inspiring
May 9, 2009

Thanks for your response. You mentioned how to get the fill color grayScale object value. But i need to find out for every TextFrame (Character) grayScale object percentage. Kindly advice me the possiblities to get the gray scale percentage values for textframes through scripting.


If the variable tFrame refers to a text frame object (ie a single block of text) --

var tFrame;

var i;

var gPercent;

for (i = 0; i < tFrame.characters.length; i ++) {

    gPercent = tFrame.characters.fillColor.gray;
}

April 25, 2009

Anyone please advice me, how to get the grayscale percentage(k value) for the illustrator files(adobe illustrator cs3) using script.

Participant
April 24, 2009

Does anyone have or know of a script that will seperate art from a layers illustrator file into seperate ai or jpeg files and name them the same name as the layer?

Thanks for your help

Larry G. Schneider
Community Expert
Community Expert
April 24, 2009

You really should have started a new topic but maybe this will work. It's modified from an export to PNG script posted last year.

/**
* @author Niels Bosma (niels.bosma@motorola.com
*/

var folder = Folder.selectDialog();
var document = app.activeDocument;
if(document && folder)
{   
    var exportOptions = new ExportOptionsJPEG();
    var type = ExportType.JPEG;
    // Setting ExportOptionsJPEG properties.
    exportOptions.antiAliasing = false;
    exportOptions.qualitySetting = 100;
    //exportOptions.artBoardClipping = true;
   
    var n = document.layers.length;
    for(var i=0; i<n; ++i)
    {
        hideAllLayers();
        var layer = document.layers;
        layer.visible = true;
   
        var file = new File(folder.fsName+"/"+layer.name+".jpg");
        document.exportFile(file, type, exportOptions);   
    }
   
    showAllLayers();
}

function hideAllLayers()
{
    forEach(document.layers, function(layer) {
        layer.visible = false;
    });
}

function showAllLayers()
{
    forEach(document.layers, function(layer) {
        layer.visible = true;
    });       
}

function forEach(collection, fn)
{
    var n = collection.length;
    for(var i=0; i<n; ++i)
    {
        fn(collection);
    }
}

//Cut and paste into any text editor and save as .jsx. Put into the AI Scripts preset folder and run. It requires an open document and will ask where to save the files.