我是Indesign新手。我有一个文件,其中包含带有Photoshop剪切路径的图像。我想导出文件夹中的所有裁剪图像。我已经尝试了“复制链接到”,它成功地导出了原始图像。然而,我不想要原始图像,而是裁剪后的图像。有没有办法将所有剪切的图像导出为JPEG,而不是原始的链接图像?简而言之,我想导出没有背景的图像。我希望我说得有道理。我有大约800-1000图像,所以批处理方法将受到高度赞赏。
我在这里的一个帖子中找到了这个脚本,并对其进行了一些修改以满足我的需要。它似乎在我的大多数INDD文档中都能工作,但在其他文档中却失败了。我想知道为什么。我有时会得到这样的错误信息:错误字符串: null不是对象源: fileName =文件( rect.graphics.itemLink.filePath ).name;
我还注意到它跳过了一些对象,不会下载所有的图像。我猜它会跳过那些不在矩形中的部分。
test();
function test()
{
var myDoc = app.activeDocument,
apis = myDoc.allPageItems, rect, fileName;
while ( rect = apis.pop() )
{
if ( !(rect instanceof Rectangle) || !rect.graphics[0].isValid ){ continue;}
fileName = File ( rect.graphics[0].itemLink.filePath ).name;
fileName = fileName.replace( /\.[a-z]{2,4}$/i, '.jpg' );
app.jpegExportPreferences.exportResolution = 2400;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM;
//give it a unique name
var myFile = new File ("C:/Users/RANFacistol-Mata/Desktop/Image Trial/"+ fileName);
rect.exportFile(ExportFormat.JPG, myFile);
}
}
有没有办法修改这个脚本,让我不再遍历所有的矩形,而是遍历所有的对象,就像单击next按钮一样
然后检查该对象是否包含图像(jpg、tiff、psd、ai、eps)。如果是这样的话,我会按照上面的脚本导出它。
谢谢你的帮助!
发布于 2017-04-03 16:23:34
您可以使用以下代码段遍历文档中的链接,这将比上面的代码段花费更少的时间……您还可以使用每个链接对象的linkType属性和filePath属性来获取链接的类型('eps‘或’pdf‘等)。
var theDoc = app.documents.item(0);
var theLinkLen = theDoc.links.length;
for(var i = 0; i < theLinkLen; ++i)
{
var link = theDoc.links.item(i);
alert("link name \"" + link.name + "\"" + " has type \"" + link.linkType + "\""+ " with filePath \"" + link.filePath + "\"");
}
https://stackoverflow.com/questions/42777286
复制相似问题