Quantcast
Channel: Adobe Community : Popular Discussions - Illustrator Scripting
Viewing all articles
Browse latest Browse all 12845

Setting Color and Overprint for a placed image (it is a Grayscaled image)

$
0
0

So I am trying to set the color of an image I have placed to a spot color then set it to overprint fill.

I have successfully created a rectangle and added these attributes to it. But I cant seam to get the same to work for a placed (Grayscale) image.

 

Here is some of my code:





#target illustrator-19


var doc = app.activeDocument;
var sel = doc.selection;


var aiDocWidth = doc.width;
var iPath = sel[0].file.path + "/";//Name;
var origImage = sel[0].file;
var origImageFile = File(origImage);


  if(origImageFile.copy(decodeURI (iPath) + "/W_" + origImageFile.name)){                //iFile[0].remove();                };
var wImageFile = File(iPath+ "/W_" + origImageFile.name);


var psScript  = 'app.displayDialogs = DialogModes.NO;';        psScript += 'app.open(' + wImageFile.toSource() + ');';        psScript += 'app.activeDocument.changeMode(ChangeMode.GRAYSCALE);';         psScript += 'app.activeDocument.activeLayer.invert();';        psScript += 'app.activeDocument.close( SaveOptions.SAVECHANGES );';         psScript += 'app.displayDialogs = DialogModes.ALL;';       
btMessaging('photoshop',psScript);


placeImage(wImageFile,origImage,sel[0]);
       


function btMessaging( targetApp, script ) {           var bt = new BridgeTalk();           bt.target = targetApp;           bt.body = script;           bt.onResult = function( inBT ) { alert( 'Done…' ) };           bt.onError = function( inBT ) { alert( 'OOPS! something went wrong! :(' ) };           bt.send( 20 ); 
};


function placeImage(fName,origImage,sel){
               var aDoc = app.activeDocument;                       var aLayer = aDoc.activeLayer;                               //Flood white Color                var floodWhiteCMYK = new CMYKColor;                floodWhiteCMYK.magenta = 100;                     //White Color object                var floodWhiteSPOT = aDoc.spots.add();                floodWhiteSPOT.name = "WhiteSpot";                floodWhiteSPOT.color = floodWhiteCMYK;                floodWhiteSPOT.colorType = ColorModel.SPOT;                    //create instance of this object                var floodWhiteColorSPOT = new SpotColor();                floodWhiteColorSPOT.spot = floodWhiteSPOT;                      var pImage = aLayer.placedItems.add (origImage.top,origImage.left);            pImage.file = fName;            pImage.name = "WhiteImage";            pImage.selected = true;            pImage.fillColor = floodWhiteColorSPOT;            pImage.fillOverprint = true;                  var origI = sel;            var x = origI.position[0] + (origI.width / 2);            var y = origI.position[1] - (origI.height / 2);                       // move image            pImage.position = [x - (pImage.width / 2),y + (pImage.height / 2)];       };

Viewing all articles
Browse latest Browse all 12845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>