我有以下问题/情况:
我现在要做的是写一个脚本,给每幅图片涂上不同的颜色,例如,第1页上的图片用彩色"1",第2页上的图片用彩色"2“等等。但是我不知道如何访问图片本身(而不是画框)并改变它的颜色。这有可能吗?
提前谢谢。
发布于 2016-05-03 07:35:08
这应该能起作用。它目前为图像设置随机颜色,并且只查找矩形。你可以用
page.allPageItems而不是。(如果您也有椭圆或多边形的图像)
// the main function
var main = function() {
var doc = app.activeDocument; // get the current document
// loop the pages
for (var i = 0; i < doc.pages.length; i++) {
var page = doc.pages[i]; // isolate the page
// loop all rectangles
for(var j = 0; j < page.rectangles.length;j++){
var rect = page.rectangles[j]; // isolate a rectangle
// test if there is an image inside
if(rect.images.length > 0){
var image = rect.images[0]; // isolate the image
// asign a random color from th swatches
image.fillColor = doc.swatches[Math.floor(Math.random()* doc.swatches.length -1)];
} // end if image
} // end loop j rectangles
} // end loop i pages
} // end of main
main(); // run ithttps://stackoverflow.com/questions/36996923
复制相似问题