Copy link to clipboard
Copied
I have a long document with many photos. These photos are in groups along with their captions. They currently have the blending mode "Luminosity" applied, but I want them to have "Normal" applied.
I found this script which does exactly what I want with a little modification. But it only works on regular rectangles. If I put the rectangle in a group, the script no longer works on it. Therefore the script doesn't work for my documents because they all have images within groups. How do I modify the script to look within groups?
Here's what I have so far:
// 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.transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL;
} // end if image
} // end loop j rectangles
} // end loop i pages
} // end of main
main(); // run it
Thanks in advance!
Hi @23121922udmu, Rob beat me to it, but here's a slightly different approach—just shows there are different ways to reference objects in Indesign. 🙂
- Mark
function main() {
var doc = app.activeDocument,
graphics = doc.allGraphics;
for (var i = 0; i < graphics.length; i++) {
// set blendMode of image
graphics[i].transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL;
// set blendMode of rectangle
graphics[i].parent.transparencySetti
...
Copy link to clipboard
Copied
Hi @23121922udmu , is the blending mode applied to the group or the images within the group?
If it’s the group then this should work:
var api = app.activeDocument.allPageItems;
for (var i = 0; i < api.length; i++){
if (api[i].constructor.name == "Group") {
api[i].transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL
}
};
If it could be to the group’s images or their frames inside of the group, then you might need something like this:
var api = app.activeDocument.allPageItems;
var gi, ag;
for (var i = 0; i < api.length; i++){
if (api[i].constructor.name == "Group") {
api[i].transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL
gi = api[i].allPageItems;
for (var j = 0; j < gi.length; j++){
gi[j].transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL
ga = gi[j].allGraphics;
for (var k = 0; k < ga.length; k++){
ga[k].transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL
};
};
}
};
Copy link to clipboard
Copied
Thank you!!
Copy link to clipboard
Copied
Hi @23121922udmu, Rob beat me to it, but here's a slightly different approach—just shows there are different ways to reference objects in Indesign. 🙂
- Mark
function main() {
var doc = app.activeDocument,
graphics = doc.allGraphics;
for (var i = 0; i < graphics.length; i++) {
// set blendMode of image
graphics[i].transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL;
// set blendMode of rectangle
graphics[i].parent.transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL;
// set blendMode of group
if (graphics[i].parent.parent.constructor.name == 'Group') {
graphics[i].parent.parent.transparencySettings.blendingSettings.blendMode = BlendMode.NORMAL;
}
}
}
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Set All Graphics to Normal Blend Mode');
Copy link to clipboard
Copied
Thanks so much! This works perfectly.