我有一个包含图像的 indesign 文件,如何复制桌面上的原始图像并重新链接到文档中的副本?我在脚本中尝试了此代码(但它没有复制文件):
if(app.documents.length != 0){
if((app.documents.item(0).allGraphics.length != 0)&&(app.selection.length != 0)){
//A production version of this script would probably include
//a more complete list of graphic/page item types.
switch(app.selection[0].constructor.name){
//If a frame is selected with the Selection tool...
case "Rectangle":
case "Oval":
case "Polygon":
if(app.selection[0].graphics.length != 0){
myDisplayDialog(app.selection[0].graphics.item(0));
}
break;
//If a graphic is selected with the Direct Selection tool...
case "Image":
case "EPS":
case "PDF":
myDisplayDialog(app.selection[0]);
break;
}
}
}
function myDisplayDialog(myGraphic){
//A production version of this script would probably check the link
//status before proceeding to get the link file.
var myLink = myGraphic.itemLink;
var myLinkName = myLink.name;
var myLinkFile = File(myLink.filePath);
//A production version of this script would check to see if
//the link file is present, and whether it's an alias/shortcut
//rather than a file.
var myDialog = app.dialogs.add({name:"Rinomina immagine"});
with(myDialog.dialogColumns.add()){
with(dialogRows.add()){
with(dialogColumns.add()){
staticTexts.add({staticLabel:"Nome file:"});
}
with(dialogColumns.add()){
var myFileNameField = textEditboxes.add({editContents:myLinkName, minWidth:200});
}
}
}
var myResult = myDialog.show();
if(myResult == true){
var myFileName = myFileNameField.editContents;
myDialog.destroy();
myRenameGraphic(myLink, myLinkFile, myFileName);
}
else{
myDialog.destroy();
}
}
function myRenameGraphic(myLink, myLinkFile, myFileName){
//A production version of the script would put up an error if the
//file cannot be renamed (for whatever reason).
myLinkFile.rename(myFileName);
myLink.relink(myLinkFile);
myLink.update();
}
答案1
问题中的脚本会重命名链接图像,然后使用新名称重新链接该图像。有时这非常方便。但我不明白你的问题。
您的 INDD 中有嵌入/粘贴的图像?您需要将图像保存在硬盘上并将其作为普通链接图像放回 INDD 中吗?还有另一个脚本:
https://creativepro.com/files/kahrel/indesign/unembed_images.html