Script that opens a selected InDesign image in Photoshop
I used to have an old script that would open any image from InDesign in Photoshop in one click.
However somehow, with the newer version of InDesign, none of the scripts that I had or found online, work. (I am on Mac, InDesign 2023 and Photoshop 2024).
I am not a scripter, so I've asked ChatGPT to write one. After about an hour of several unsuccesful attempts we have finally managed to produce a working Java Script! So here I share it with you. You are welcome to improve it.
imagesToPS();
function imagesToPS() {
if (app.selection.length > 0) {
var selectedPageItem = app.selection[0]; // Assuming the first selected item is a page item
if (selectedPageItem.constructor.name == "Image") {
var filePath = selectedPageItem.itemLink.filePath;
openImageInPhotoshop(filePath);
} else {
alert("Selected item is not an image.");
}
} else {
alert("No items selected.");
}
}
function openImageInPhotoshop(filePath) {
try {
var bt = new BridgeTalk();
bt.target = "photoshop";
bt.body = 'app.bringToFront(); app.open(new File("' + filePath + '"));';
bt.onError = function (inBT) {
alert("Error opening image in Photoshop: " + inBT.body);
};
bt.onResult = function (resObj) {};
bt.send();
} catch (e) {
alert("Error opening image in Photoshop: " + e);
}
}
