• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
2

Embedding image using a script - wrong size

Community Beginner ,
Mar 18, 2024 Mar 18, 2024

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);

 

TOPICS
Actions and scripting , macOS

Views

70

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Mar 18, 2024 Mar 18, 2024

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
...

Votes

Translate

Translate
Adobe
Community Expert ,
Mar 18, 2024 Mar 18, 2024

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);
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Mar 19, 2024 Mar 19, 2024

Copy link to clipboard

Copied

LATEST

Thank you! It worked 🙂

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines