![](/img/trans.png)
[英]Changing an Indesign Swatch incrementally with Extendscript (JavaScript)
[英]How to change color swatch of colored greyscale pictures using ExtendScript in InDesign?
我有以下問題/情況:
我現在要做的是編寫一個腳本,用不同的顏色樣本為每張圖片着色,例如第1頁上的圖片,色樣“1”,第2頁上的圖片,色樣“2”等。但是我不知道如何訪問圖片本身(而不是框架)並改變其顏色。 這甚至可能嗎?
提前致謝。
這應該可以解決問題。 它目前為圖像設置隨機顏色,僅查找矩形。 你可以用
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 it
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.