0

我整天都在谷歌搜索,以找到一种通过脚本将图层与画布对齐的方法,但到目前为止还没有找到解决方案。我最终得到了下面的代码,但它不能完成这项工作。有人可以帮忙吗?

var baseFile = new File(openDialog()); //open base JPEG file
var workFile = new File(openDialog()); //open work JPEG file
var baseDoc = app.open(baseFile);
var workDoc = app.open(workFile);

workDoc.resizeImage(280,280);
workDoc.artLayers[0].duplicate(baseDoc, ElementPlacement.INSIDE);
app.activeDocument = baseDoc;

var Hoffset = (baseDoc.width - workDoc.width) / 2;
var Voffset = (baseDoc.height - workDoc.height) / 2;
baseDoc.layers[1].position = Array(Hoffset, Voffset);
4

0 回答 0