Copy link to clipboard
Copied
Hi,
Using the following script I try to embed an image from one file to an image from another file. The files are at the same resolution (px and dpi). When embedded manually, it inserts correctly, filling the whole picture. But when embedded via scrip, it is resize to something around 10% of the original dimensions.
How can I fix it?
placeEmbeded(filePath);
function placeEmbeded(filePath) {
var actDesc = new ActionDescriptor();
actDesc.putPath(charIDToTypeID('null'), filePath);
actDesc.putEnumerated(charIDToTypeID('FTcs'), charIDToTypeID('QCSt'), charIDToTypeID('Qcsa'));
executeAction(charIDToTypeID('Plc '), actDesc, DialogModes.NO);
Your code doesn't work for me (even when adding the missing closing brace).
This works for me:
placeFile(new File("~/Desktop/place.psd"), false, 0, 0);
function placeFile(thePath, linked, xPosition, yPosition) {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var AD = new ActionDescriptor();
AD.putInteger(s2t("ID"), 1);
AD.putPath(s2t("null"), thePath); // file path
AD.putBoolean(s2t("linked"), linked); // false for embedded
AD.putEnumerated(s
...
Copy link to clipboard
Copied
Your code doesn't work for me (even when adding the missing closing brace).
This works for me:
placeFile(new File("~/Desktop/place.psd"), false, 0, 0);
function placeFile(thePath, linked, xPosition, yPosition) {
var s2t = function (s) {
return app.stringIDToTypeID(s);
};
var AD = new ActionDescriptor();
AD.putInteger(s2t("ID"), 1);
AD.putPath(s2t("null"), thePath); // file path
AD.putBoolean(s2t("linked"), linked); // false for embedded
AD.putEnumerated(s2t("freeTransformCenterState"), s2t("quadCenterState"), s2t("QCSAverage")); // transform
AD.putUnitDouble(s2t("horizontal"), s2t("pixelsUnit"), xPosition); // x coordinate position
AD.putUnitDouble(s2t("vertical"), s2t("pixelsUnit"), yPosition); // y coordinate position
executeAction(s2t("placeEvent"), AD, DialogModes.NO);
}
Copy link to clipboard
Copied
Thank you! It worked 🙂