Skip to main content
Stephen Marsh
Brainiac
September 22, 2015
Answered

Change Spot Colour Opacity Value to Tint Value

  • September 22, 2015
  • 1 reply
  • 3116 views

Does anyone know of a script to change all spot colour objects that have an opacity value to the corresponding tint value of the spot colour? It could also be for process colours, global or not – however the main thing is spots.


If an object uses a spot colour that has an opacity of say 13%, then it should be set to opacity 100% and the spot colour tint value of 13%. If an object was 75% opacity, then it should be set to 75% tint at 100% opacity etc. All the way through the tonal range for all objects.


It would be nice if the blend mode of the spot colour was set to normal if it was something else (darken, multiply etc). I guess it would also be great if there was an option to set the object to overprint if the blend mode used was darken or multiply, but that is the icing on the cake. The main thing is mapping the spot object opacity value to the spot tint value and setting opacity back to 100%.


I would have thought that this would be a common enough issue in packaging prepress, however I have had no success in finding such a script.

This topic has been closed for replies.
Correct answer Qwertyfly___

you lose your original opacity value if its run as separate scripts.

here is how to do it as one script

var doc = app.activeDocument; 

//var items = doc.pageItems; // this line states that items is an array of all page Items 

var items = doc.selection; // this line states that items is an array of all selected items 

for(var i = 0; i<items.length;i++){ 

    if(items.opacity != 100){ 

        if(items.filled === true){

            items.fillColor.tint = items.fillColor.tint*(items.opacity/100);

        }

        if(items.stroked === true){

            items.strokeColor.tint = items.strokeColor.tint*(items.opacity/100);

        }

        items.opacity = 100; 

    } 

}

As for actions losing the script on restart.

CC+ still has the same issue.

very painfull


here is a more complete script.

bundled in a function to keep global space clean.

and should deal with Spot, CMYK, and RGB colours.

let me know if you find it does unexpected things...

function RemoveOpacity(){

    // to work on selected items only set to SEL

    // to work on whole document set to ALL

    var work_on = "SEL";

    //---------------------------------------------------------

    var doc = app.activeDocument; 

    if(work_on === 'SEL'){

        var items = doc.selection;

    }else if(work_on === 'ALL'){

        var items = doc.pathItems;

    }else{

        alert('the "work_on" variable is not set correctly');

        return;

    }

    for(var i = 0; i<items.length;i++){ 

        if(items.opacity != 100){ 

            if(items.filled === true && items.fillColor == '[SpotColor]'){

                items.fillColor.tint = items.fillColor.tint*(items.opacity/100);

            }else if(items.filled === true && items.fillColor == '[CMYKColor]'){

                items.fillColor.cyan = items.fillColor.cyan*(items.opacity/100);

                items.fillColor.magenta = items.fillColor.magenta*(items.opacity/100);

                items.fillColor.yellow = items.fillColor.yellow*(items.opacity/100);

                items.fillColor.black = items.fillColor.black*(items.opacity/100);

            }else if(items.filled === true && items.fillColor == '[RGBColor]'){

                items.fillColor.red = items.fillColor.red+(255-items.fillColor.red)*(items.opacity/100);

                items.fillColor.blue = items.fillColor.blue+(255-items.fillColor.blue)*(items.opacity/100);

                items.fillColor.green = items.fillColor.green+(255-items.fillColor.green)*(items.opacity/100);

            }

            if(items.stroked === true && items.strokeColor == '[SpotColor]'){

                items.strokeColor.tint = items.strokeColor.tint*(items.opacity/100);

            }else if(items.stroked === true && items.strokeColor == '[CMYKColor]'){

                items.strokeColor.cyan = items.strokeColor.cyan*(items.opacity/100);

                items.strokeColor.magenta = items.strokeColor.magenta*(items.opacity/100);

                items.strokeColor.yellow = items.strokeColor.yellow*(items.opacity/100);

                items.strokeColor.black = items.strokeColor.black*(items.opacity/100);

            }else if(items.stroked === true && items.strokeColor == '[RGBColor]'){

                items.strokeColor.red = items.strokeColor.red+(255-items.strokeColor.red)*(items.opacity/100);

                items.strokeColor.blue = items.strokeColor.blue+(255-items.strokeColor.blue)*(items.opacity/100);

                items.strokeColor.green = items.strokeColor.green+(255-items.strokeColor.green)*(items.opacity/100);

            }

            items.opacity = 100; 

        } 

    }

}

RemoveOpacity();

1 reply

Qwertyfly___
Brainiac
September 23, 2015

this is not a hard one to do.

but would a flatten transparency be a better option?

here is what you want in its most basic form.

var doc = app.activeDocument;

var items = doc.pageItems;

for(var i = 0; i<items.length;i++){

    items.fillColor.tint = items.opacity;

    items.opacity = 100;

}

image of before:

and image of after:

you can quickly see the issue once you remove your transparency.

Stephen Marsh
Brainiac
September 23, 2015

That is great Qwertyfly, thank you so much! Even six lines of code is beyond my abilities…

Although this script produces the desired change in objects with opacity below 100%, the sript adversely affects spot colour objects that do not have opacity applied.

I have tried only selecting the desired objects to change, inverse selection and locking or hiding the objects that don’t use opacity – however they are still affected by the script.

Is there an easy way to limit this script change to only objects that are less than 100% opacity?

Flattening transparency preserving spots sort of works, however it faithfully preserves overlapping regions and attempts to visually represent the interaction of opacity in the flattened document. Opacity applied to spot and tint applied to spot are similar, but subtly different – so I prefer your script results.

Qwertyfly___
Brainiac
September 23, 2015

we can just add an If statement.

If opacity not 100

set tint to opacity

set opacity to 100

else do nothing

I also added a Line that has been commented out.

if you remove the // from the start of line 3 and add // to the start of line 2.

then it will only act on selected items.

var doc = app.activeDocument;

var items = doc.pageItems; // this line states that items is an array of all page Items

//var items = doc.selection; // this line states that items is an array of all selected items

for(var i = 0; i<items.length;i++){

    if(items.opacity != 100){

        items.fillColor.tint = items.opacity;

        items.opacity = 100;

    }

}

remember this is about as basic as it gets and may do undesired things in certain situations.

ie.

if tint = 50 & opacity = 50.

tint gets set to opacity and opacity is set to 100

tint now 50 and opacity is now 100.

this should be 25.

so to fix that we need some maths (this example I have switched to selection mode)

var doc = app.activeDocument;

//var items = doc.pageItems; // this line states that items is an array of all page Items

var items = doc.selection; // this line states that items is an array of all selected items

for(var i = 0; i<items.length;i++){

    if(items.opacity != 100){

        items.fillColor.tint = items.fillColor.tint*(items.opacity/100);

        items.opacity = 100;

    }

}

but remember tint and opacity are not equal.

you will probably be modifying a lot of your colours.

ie.