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

Is it possible to copy all Width Height, X and Y properties?

Explorer ,
Dec 10, 2022 Dec 10, 2022

Copy link to clipboard

Copied

Hello,

 

Is there any easy ways to copy Width Height X and Y of a layer so I can apply it to other layer (as a replacement) on the same image

 

01.jpg

 

Any help and suggestion will be appreciated, Thank you

TOPICS
Actions and scripting , Windows

Views

3.0K

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 2 Correct answers

Community Expert , Dec 11, 2022 Dec 11, 2022

Update - 17th December 2022:

 

Here is a simplified 2 part script, replacing all previously posted code in this topic.

 

Select the source layer and run script 1 of 2:

 

/*
Resize Target Layer to Source Layer Size - 1 of 2.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/is-it-possible-to-copy-all-width-height-x-and-y-properties/td-p/13410970
v1.1, 17th December 2022, Stephen Marsh
*/

#target photoshop

if (documents.length) {

    // Store the original ruler units and set to 
...

Votes

Translate

Translate
Community Expert , Dec 11, 2022 Dec 11, 2022

Update - 19th December 2022:

 

/* The previous code using the $.setenv() code has been removed due to errors */

 

Here is a single OPT/ALT version of the updated two-part script:

 

/*
Resize Target Layer to Source Layer Size - ALT-OPT.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/is-it-possible-to-copy-all-width-height-x-and-y-properties/td-p/13410970
v1.1, 19th December 2022, Stephen Marsh
*/

#target photoshop

if (documents.length) {

    /* Step 2 - Hold down alt/opt to 
...

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 10, 2022 Dec 10, 2022

Copy link to clipboard

Copied

@DesainFreak2706 – I'm not sure about the properties panel, it seems to leverage the standard transform command in the background, just slightly differently than when using the transform command. Also keep in mind that as soon as one enters a value and tabs to the next field, the value is automatically applied before the next field is entered. The transform command allows both fields to be adjusted before the transform is committed/applied.

 

The standard transform toolbar command works in %, so you either work out the % or use other tricks to work in px values.

 

The following topic contains scripts to automatically resize layer "B" using the size of layer "A":

 

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
Explorer ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

Thank you for the reply

 

your latest script that I have tried does generate files with coordinate,

this is the results when I run the "Resize Layer from Source - Script 1 of 2.jsx" while select the layer that i want to copy.

01.jpg02.jpg

 

But when I run the "Resize Layer from Source - Script 2 of 2.jsx", it delete the target layer.

 

-------

And then I find the other script you've made from the topic that you gave to me and it does success resize layer B based on layer A size, but the layer B coordinate does not same as layer A coordinate

 

03.jpg

04.jpg

05.jpg

 

am I doing something wrong? please advise

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 Expert ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

I'll post a  new, simplified version (a lot was probably going on that may or may not have any relevance to your situation). The properties panel resizes from a fixed upper left reference point, while transform allows nine reference points.

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
Explorer ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

Thanks, I am glad that you can help me here to solve the complicated process that I've been through. hopefully it does can do the purpose. Thank you for your help!

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 Expert ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

Update - 17th December 2022:

 

Here is a simplified 2 part script, replacing all previously posted code in this topic.

 

Select the source layer and run script 1 of 2:

 

/*
Resize Target Layer to Source Layer Size - 1 of 2.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/is-it-possible-to-copy-all-width-height-x-and-y-properties/td-p/13410970
v1.1, 17th December 2022, Stephen Marsh
*/

#target photoshop

if (documents.length) {

    // Store the original ruler units and set to px
    var savedRuler = app.preferences.rulerUnits;
    app.preferences.rulerUnits = Units.PIXELS;

    // Set the layer dimension variables
    try {
        var idcopyEffects = stringIDToTypeID("copyEffects");
        executeAction(idcopyEffects, undefined, DialogModes.NO);
        var iddisableLayerStyle = stringIDToTypeID("disableLayerStyle");
        executeAction(iddisableLayerStyle, undefined, DialogModes.NO);
    } catch (error) {
        //alert(error);
    }

    var layerWidth = (activeDocument.activeLayer.bounds[2] - activeDocument.activeLayer.bounds[0]);
    var layerHeight = (activeDocument.activeLayer.bounds[3] - activeDocument.activeLayer.bounds[1]);
    var sourceLayer = activeDocument.activeLayer.id;

    try {
        var idpasteEffects = stringIDToTypeID("pasteEffects");
        executeAction(idpasteEffects, undefined, DialogModes.NO);
    } catch (error) {
        //alert(error);
    }

    // Log text file platform specific LF options
    var os = $.os.toLowerCase().indexOf("mac") >= 0 ? "mac" : "windows";
    if (os === "mac") {
        prefFileOutLF = "Unix"; // Legacy = "Macintosh"
    } else {
        prefFileOutLF = "Windows";
    }
    // Create the preference file
    var prefFileOut = new File('~/Desktop/_Resize_Layer_Preference_File.txt');
    var dateTime = new Date().toLocaleString();
    if (prefFileOut.exists)
        prefFileOut.remove();
    prefFileOut.open("w");
    prefFileOut.encoding = "UTF-8";
    prefFileOut.lineFeed = prefFileOutLF;
    prefFileOut.writeln(dateTime + ", " + "Source Doc: " + activeDocument.name + ", " + "Source Layer: " + activeDocument.activeLayer.name);
    prefFileOut.writeln(layerWidth.value);
    prefFileOut.writeln(layerHeight.value);
    prefFileOut.writeln(sourceLayer);
    prefFileOut.close();

    // Restore the original ruler units
    app.preferences.rulerUnits = savedRuler;

    // End of script notification
    alert("Select the target layer/s and run the script again while holding down the ALT/OPT key to transform.");

} else {
    alert("A document must be open to run this script!");
}

 

 

 

Select one or more target layers and run the 2 of 2 script (a single history step undo is included):

 

 

/*
Resize Target Layer to Source Layer Size - 2 of 2.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/is-it-possible-to-copy-all-width-height-x-and-y-properties/td-p/13410970
v1.1, 17th December 2022, Stephen Marsh
*/

#target photoshop

if (documents.length) {

    function main() {

        try {
            var prefFileIn = File('~/Desktop/_Resize_Layer_Preference_File.txt');
        } catch (e) {
            alert(e);
        }

        if (File(prefFileIn).exists && File(prefFileIn).length > 0) {

            // Read the preference file from the user's desktop
            prefFileIn.open('r');
            // Read the 1st line from the log file, a means to an end...
            var logInfo = prefFileIn.readln(1);
            // Read the 2nd line from the log file & convert the string to a number/integer
            var prefFileWidthValue = Math.floor(prefFileIn.readln(2));
            // Read the 3rd line from the log file & convert the string to a number/integer
            var prefFileHeightValue = Math.floor(prefFileIn.readln(3));
            var prefFileSourceLayer = prefFileIn.readln(4);
            prefFileIn.close();

            processSelectedLayers();

            prefFileIn.remove();

            // End of script notification
            //app.refresh();
            alert("Script completed!" + "\r" + "Target layer resized to source layer size/position");


            // Functions

            function processSelectedLayers() {
                var s2t = stringIDToTypeID;
                (r = new ActionReference).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
                r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
                var lrs = executeActionGet(r).getList(p),
                    sel = new ActionReference();

                for (var i = 0; i < lrs.count; i++) {
                    sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
                    (r = new ActionReference).putIdentifier(s2t('layer'), p);
                    (d = new ActionDescriptor()).putReference(s2t("target"), r);
                    executeAction(s2t('select'), d, DialogModes.NO);

                    // Call the resize layer function
                    resizeLayerFromPrefFile();

                    // Apply any layer styles from source layer to target layer
                    try {
                        var idpasteEffects = stringIDToTypeID("pasteEffects");
                        executeAction(idpasteEffects, undefined, DialogModes.NO);
                    } catch (error) {
                        //alert(error);
                    }
                }
            }

            function resizeLayerFromPrefFile() {
                // Store the original ruler units and set to px
                var savedRuler = app.preferences.rulerUnits;
                app.preferences.rulerUnits = Units.PIXELS;

                // Create variables to hold the target layer dimensions
                var targetLayerWidth = activeDocument.activeLayer.bounds[2] - activeDocument.activeLayer.bounds[0];
                var targetLayerHeight = activeDocument.activeLayer.bounds[3] - activeDocument.activeLayer.bounds[1];

                // Calculate the % adjustment value
                var targetLayerScaleWidth = prefFileWidthValue / targetLayerWidth * 100;
                var targetLayerScaleHeight = prefFileHeightValue / targetLayerHeight * 100;

                // Transform from upper left
                transform(0, 0, targetLayerScaleWidth, targetLayerScaleHeight);

                // Alignment
                targetLayer = activeDocument.activeLayer;
                selectLayerById(prefFileSourceLayer);
                transparencySelection();
                activeDocument.activeLayer = targetLayer;
                align2Selection('AdLf');
                align2Selection('AdTp');
                activeDocument.selection.deselect();

                // Restore the original ruler units
                app.preferences.rulerUnits = savedRuler;


                // Functions

                function transparencySelection() {
                    function s2t(s) {
                        return app.stringIDToTypeID(s);
                    }
                    var descriptor = new ActionDescriptor();
                    var reference = new ActionReference();
                    var reference2 = new ActionReference();
                    reference.putProperty(s2t("channel"), s2t("selection"));
                    descriptor.putReference(s2t("null"), reference);
                    reference2.putEnumerated(s2t("channel"), s2t("channel"), s2t("transparencyEnum"));
                    descriptor.putReference(s2t("to"), reference2);
                    executeAction(s2t("set"), descriptor, DialogModes.NO);
                }

                function align2Selection(method) {
                    var desc = new ActionDescriptor();
                    var ref = new ActionReference();
                    ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
                    desc.putReference(charIDToTypeID("null"), ref);
                    desc.putEnumerated(charIDToTypeID("Usng"), charIDToTypeID("ADSt"), charIDToTypeID(method));
                    try {
                        executeAction(charIDToTypeID("Algn"), desc, DialogModes.NO);
                    } catch (e) {}
                }

                function transform(horizontal, vertical, width, height) {
                    function s2t(s) {
                        return app.stringIDToTypeID(s);
                    }
                    var descriptor = new ActionDescriptor();
                    var descriptor2 = new ActionDescriptor();
                    var reference = new ActionReference();
                    reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
                    descriptor.putReference(s2t("null"), reference);
                    descriptor.putEnumerated(s2t("freeTransformCenterState"), s2t("quadCenterState"), s2t("QCSCorner0"));
                    descriptor2.putUnitDouble(s2t("horizontal"), s2t("pixelsUnit"), horizontal);
                    descriptor2.putUnitDouble(s2t("vertical"), s2t("pixelsUnit"), vertical);
                    descriptor.putObject(s2t("offset"), s2t("offset"), descriptor2);
                    descriptor.putUnitDouble(s2t("width"), s2t("percentUnit"), width);
                    descriptor.putUnitDouble(s2t("height"), s2t("percentUnit"), height);
                    descriptor.putEnumerated(s2t("interfaceIconFrameDimmed"), s2t("interpolationType"), s2t("bicubicAutomatic"));
                    executeAction(s2t("transform"), descriptor, DialogModes.NO);
                }

                function selectLayerById(id)
                /* https://graphicdesign.stackexchange.com/questions/130739/photoshop-scripting-applying-changes-only-to-selected-artboards */
                {
                    var desc1 = new ActionDescriptor();
                    var ref1 = new ActionReference();
                    ref1.putIdentifier(charIDToTypeID('Lyr '), id);
                    desc1.putReference(charIDToTypeID('null'), ref1);
                    executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
                }

            }


        } else {
            app.beep();
            alert('There is no valid file named "_Resize_Layer_Preference_File.txt" on the desktop!');
        }
    }

    activeDocument.suspendHistory("Resize selected layers script", "main()");

} else {
    alert("A document must be open to run this script!");
}

 

 

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 Expert ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

Update - 19th December 2022:

 

/* The previous code using the $.setenv() code has been removed due to errors */

 

Here is a single OPT/ALT version of the updated two-part script:

 

/*
Resize Target Layer to Source Layer Size - ALT-OPT.jsx
https://community.adobe.com/t5/photoshop-ecosystem-discussions/is-it-possible-to-copy-all-width-height-x-and-y-properties/td-p/13410970
v1.1, 19th December 2022, Stephen Marsh
*/

#target photoshop

if (documents.length) {

    /* Step 2 - Hold down alt/opt to resize the layer */
    if (ScriptUI.environment.keyboardState.altKey) {

        function main() {

            try {
                var prefFileIn = File('~/Desktop/_Resize_Layer_Preference_File.txt');
            } catch (e) {
                alert(e);
            }

            if (File(prefFileIn).exists && File(prefFileIn).length > 0) {

                // Read the preference file from the user's desktop
                prefFileIn.open('r');
                // Read the 1st line from the log file, a means to an end...
                var logInfo = prefFileIn.readln(1);
                // Read the 2nd line from the log file & convert the string to a number/integer
                var prefFileWidthValue = Math.floor(prefFileIn.readln(2));
                // Read the 3rd line from the log file & convert the string to a number/integer
                var prefFileHeightValue = Math.floor(prefFileIn.readln(3));
                var prefFileSourceLayer = prefFileIn.readln(4);
                prefFileIn.close();

                processSelectedLayers();

                prefFileIn.remove();

                // End of script notification
                //app.refresh();
                alert("Script completed!" + "\r" + "Target layer resized to source layer size/position");


                // Functions

                function processSelectedLayers() {
                    var s2t = stringIDToTypeID;
                    (r = new ActionReference).putProperty(s2t('property'), p = s2t('targetLayersIDs'));
                    r.putEnumerated(s2t('document'), s2t('ordinal'), s2t('targetEnum'));
                    var lrs = executeActionGet(r).getList(p),
                        sel = new ActionReference();

                    for (var i = 0; i < lrs.count; i++) {
                        sel.putIdentifier(s2t('layer'), p = lrs.getReference(i).getIdentifier(s2t('layerID')));
                        (r = new ActionReference).putIdentifier(s2t('layer'), p);
                        (d = new ActionDescriptor()).putReference(s2t("target"), r);
                        executeAction(s2t('select'), d, DialogModes.NO);

                        // Call the resize layer function
                        resizeLayerFromPrefFile();

                        // Apply any layer styles from source layer to target layer
                        try {
                            var idpasteEffects = stringIDToTypeID("pasteEffects");
                            executeAction(idpasteEffects, undefined, DialogModes.NO);
                        } catch (error) {
                            //alert(error);
                        }
                    }
                }

                function resizeLayerFromPrefFile() {
                    // Store the original ruler units and set to px
                    var savedRuler = app.preferences.rulerUnits;
                    app.preferences.rulerUnits = Units.PIXELS;

                    // Create variables to hold the target layer dimensions
                    var targetLayerWidth = activeDocument.activeLayer.bounds[2] - activeDocument.activeLayer.bounds[0];
                    var targetLayerHeight = activeDocument.activeLayer.bounds[3] - activeDocument.activeLayer.bounds[1];

                    // Calculate the % adjustment value
                    var targetLayerScaleWidth = prefFileWidthValue / targetLayerWidth * 100;
                    var targetLayerScaleHeight = prefFileHeightValue / targetLayerHeight * 100;

                    // Transform from upper left
                    transform(0, 0, targetLayerScaleWidth, targetLayerScaleHeight);

                    // Alignment
                    targetLayer = activeDocument.activeLayer;
                    selectLayerById(prefFileSourceLayer);
                    transparencySelection();
                    activeDocument.activeLayer = targetLayer;
                    align2Selection('AdLf');
                    align2Selection('AdTp');
                    activeDocument.selection.deselect();

                    // Restore the original ruler units
                    app.preferences.rulerUnits = savedRuler;


                    // Functions

                    function transparencySelection() {
                        function s2t(s) {
                            return app.stringIDToTypeID(s);
                        }
                        var descriptor = new ActionDescriptor();
                        var reference = new ActionReference();
                        var reference2 = new ActionReference();
                        reference.putProperty(s2t("channel"), s2t("selection"));
                        descriptor.putReference(s2t("null"), reference);
                        reference2.putEnumerated(s2t("channel"), s2t("channel"), s2t("transparencyEnum"));
                        descriptor.putReference(s2t("to"), reference2);
                        executeAction(s2t("set"), descriptor, DialogModes.NO);
                    }

                    function align2Selection(method) {
                        var desc = new ActionDescriptor();
                        var ref = new ActionReference();
                        ref.putEnumerated(charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
                        desc.putReference(charIDToTypeID("null"), ref);
                        desc.putEnumerated(charIDToTypeID("Usng"), charIDToTypeID("ADSt"), charIDToTypeID(method));
                        try {
                            executeAction(charIDToTypeID("Algn"), desc, DialogModes.NO);
                        } catch (e) {}
                    }

                    function transform(horizontal, vertical, width, height) {
                        function s2t(s) {
                            return app.stringIDToTypeID(s);
                        }
                        var descriptor = new ActionDescriptor();
                        var descriptor2 = new ActionDescriptor();
                        var reference = new ActionReference();
                        reference.putEnumerated(s2t("layer"), s2t("ordinal"), s2t("targetEnum"));
                        descriptor.putReference(s2t("null"), reference);
                        descriptor.putEnumerated(s2t("freeTransformCenterState"), s2t("quadCenterState"), s2t("QCSCorner0"));
                        descriptor2.putUnitDouble(s2t("horizontal"), s2t("pixelsUnit"), horizontal);
                        descriptor2.putUnitDouble(s2t("vertical"), s2t("pixelsUnit"), vertical);
                        descriptor.putObject(s2t("offset"), s2t("offset"), descriptor2);
                        descriptor.putUnitDouble(s2t("width"), s2t("percentUnit"), width);
                        descriptor.putUnitDouble(s2t("height"), s2t("percentUnit"), height);
                        descriptor.putEnumerated(s2t("interfaceIconFrameDimmed"), s2t("interpolationType"), s2t("bicubicAutomatic"));
                        executeAction(s2t("transform"), descriptor, DialogModes.NO);
                    }

                    function selectLayerById(id)
                    /* https://graphicdesign.stackexchange.com/questions/130739/photoshop-scripting-applying-changes-only-to-selected-artboards */
                    {
                        var desc1 = new ActionDescriptor();
                        var ref1 = new ActionReference();
                        ref1.putIdentifier(charIDToTypeID('Lyr '), id);
                        desc1.putReference(charIDToTypeID('null'), ref1);
                        executeAction(charIDToTypeID('slct'), desc1, DialogModes.NO);
                    }

                }


            } else {
                app.beep();
                alert('There is no valid file named "_Resize_Layer_Preference_File.txt" on the desktop!');
            }
        }

        activeDocument.suspendHistory("Resize selected layers script", "main()");

    /* Step 1 - Set the target group and layer */
    } else {

        // Store the original ruler units and set to px
        var savedRuler = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        // Set the layer dimension variables
        try {
            var idcopyEffects = stringIDToTypeID("copyEffects");
            executeAction(idcopyEffects, undefined, DialogModes.NO);
            var iddisableLayerStyle = stringIDToTypeID("disableLayerStyle");
            executeAction(iddisableLayerStyle, undefined, DialogModes.NO);
        } catch (error) {
            //alert(error);
        }

        var layerWidth = (activeDocument.activeLayer.bounds[2] - activeDocument.activeLayer.bounds[0]);
        var layerHeight = (activeDocument.activeLayer.bounds[3] - activeDocument.activeLayer.bounds[1]);
        var sourceLayer = activeDocument.activeLayer.id;

        try {
            var idpasteEffects = stringIDToTypeID("pasteEffects");
            executeAction(idpasteEffects, undefined, DialogModes.NO);
        } catch (error) {
            //alert(error);
        }

        // Log text file platform specific LF options
        var os = $.os.toLowerCase().indexOf("mac") >= 0 ? "mac" : "windows";
        if (os === "mac") {
            prefFileOutLF = "Unix"; // Legacy = "Macintosh"
        } else {
            prefFileOutLF = "Windows";
        }
        // Create the preference file
        var prefFileOut = new File('~/Desktop/_Resize_Layer_Preference_File.txt');
        var dateTime = new Date().toLocaleString();
        if (prefFileOut.exists)
            prefFileOut.remove();
        prefFileOut.open("w");
        prefFileOut.encoding = "UTF-8";
        prefFileOut.lineFeed = prefFileOutLF;
        prefFileOut.writeln(dateTime + ", " + "Source Doc: " + activeDocument.name + ", " + "Source Layer: " + activeDocument.activeLayer.name);
        prefFileOut.writeln(layerWidth.value);
        prefFileOut.writeln(layerHeight.value);
        prefFileOut.writeln(sourceLayer);
        prefFileOut.close();

        // Restore the original ruler units
        app.preferences.rulerUnits = savedRuler;

        // End of script notification
        alert("Select the target layer/s and run the script again while holding down the ALT/OPT key to transform.");

    }

} else {
    alert("A document must be open to run this script!");
}

 

 

 

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
Explorer ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

I have follow your instructions step by step,

1. I copied the script to photoshop script folder so its show inside the menu

01.jpg

2. I try the first attempt running the script and succeed; it shown like this

05.jpg

3. after that I select the target layer and re-running the script while holding the alt key (I am using windows 10), and it shown error like this

06.jpg

Perhaps I'm doing something wrong in the process.

 

I want to show you what I'm trying to do here

1. I have source layer with W400px H266px and coordinate X169px Y4326px, lets call this layer A

02.jpg

 

2. I have new image which I open as layer B with details W1848px H1230px X1167px Y4072px.

- I want this Layer B to have exact numbers from layer A, which is W400px H266px X169px Y4326px

- Usually I've done this one by one manual editing those number WHXY so the Layer B will match the Layer A

- My purpose is to replace Layer A into Layer B, which of course i should transform layer B so it will match the size and coordinate of Layer A

03.jpg

 

 

 

 

 

 

 

3. This is the final results of all those actions

04.jpg

 

Please advise, thank you in advance and best regards

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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
Explorer ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

Thanks for the detail info, I have followed your step by step guideline and here what happened

 

  1. I have copy all scripts to the script photoshop folder, so it show up on the file / scripts menu

 

01.jpg

 

2. I have run the latest script that you've submit and it works successfuly on the first process

 

05.jpg

 

3. On the process it show error message though I had hold down the ALT key while re-running the script

06.jpg

Am I doing something wrong on the process? please advise

 

 

 

 

 

 

 

 

 

 

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 Expert ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

Remove all versions and only install the latest version. Make sure that opt/alt is depressed before and while selecting the script.

 

 I'll break it up into two scripts if that helps.

 

The error means that the size variables from the first run have been lost.

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
Explorer ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

I've tried running the script many times, restart photoshop couple of times and even I restart my windows 10 twice with no luck. The same error message keep showing up. I use the latest photoshop ver. 24.0.1

 

 

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 Expert ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

OK, I'll look into it, thanks!

 

EDIT: I don't know what the problem is... I have compared the $.setenv() to what I have used previously and can't find the issue. I'll need to go back to writing to a text file if this can't be sorted. :[

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
Explorer ,
Dec 12, 2022 Dec 12, 2022

Copy link to clipboard

Copied

no problem, I just hoping this can be done with script.

I think I will use actions to solve this, though it will be complicated 😄

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 Expert ,
Dec 13, 2022 Dec 13, 2022

Copy link to clipboard

Copied

It can be done via a script. I was hoping that someone would come along and correct the errors in my script. So I'll need to rewrite it to use variables stored in a text file rather than $.setenv()

 

P.S. A smart object replacement workflow would be an alternative.

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 Expert ,
Dec 14, 2022 Dec 14, 2022

Copy link to clipboard

Copied

@DesainFreak2706 – I have replaced/updated the previous script code with two separate scripts. I'll also combine them into a single script using the OPT/ALT key to run the second step.

 

I have given up for now on using Photoshop environment variables – instead, these updated scripts write the data to a temporary text log/pref file.

 

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
Explorer ,
Dec 11, 2022 Dec 11, 2022

Copy link to clipboard

Copied

Maybe I can post a little bit what I do manually on this process

 

1. I select source layer, lets call it Layer A; with details

02.jpg

 

2. And there is target layer, lets call it layer B with details below

Usually I change all Layer B details to match Layer A (with the purpose Layer B to replace Layer A)

03.jpg

 

3. After details on Layer B has changed match to Layer A, then it will replaced Layer A coordinate; and usually I delete the Layer A

04.jpg

 

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
Explorer ,
Dec 16, 2022 Dec 16, 2022

Copy link to clipboard

Copied

THIS IS WORKING SCRIPT!! THANK YOU!

 

the coordinate is correct; but with one exception, the script is not correct while grabbing the width and height of source layer size, hence the results size also not the same as the source

 

size.jpg

 

like you see, the source should be 400x266, but it read 419x285

if this solve then it will be the perfect one! Thank you for your effort until now, really appreciate it!

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 Expert ,
Dec 16, 2022 Dec 16, 2022

Copy link to clipboard

Copied

Please upload the file for testing as this does not reflect the tests that I performed with my files.

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
Explorer ,
Dec 16, 2022 Dec 16, 2022

Copy link to clipboard

Copied

The problem seems lies on the layer style, I put layer style "stroke and drop shadow" on the source layer, i think that what caused the size havoc all this time. If I clear those style, your script works fine.

 

I have upload the sample file, the small layers are the source, the big one is the target, please test it. thank you

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 Expert ,
Dec 16, 2022 Dec 16, 2022

Copy link to clipboard

Copied

@DesainFreak2706 – Yes, as you are using layer styles this changes things... This wasn't expected or previously mentioned. This isn't an insurmountable problem though and should only require minor edits...

 

EDIT:

I have reworked the 1 of 2 and 2 of 2 scripts to a v1.1 17th December update. I'll update the ALT/OPT single script version once you confirm that this update works as expected.

 

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
Explorer ,
Dec 16, 2022 Dec 16, 2022

Copy link to clipboard

Copied

sorry for not mentioning the style, I'm not expecting the layer would cause problem in the script itself.

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 Expert ,
Dec 16, 2022 Dec 16, 2022

Copy link to clipboard

Copied

No worries, live and learn! Un-rasterized styles that affect the source layer pixels are not calculated via scripting bounds. The newly updated versions of the script now account for this.

 

NOTE: the last copied layer style will be pasted onto the target layer/s, which will need to be manually cleared if it isn't required for a layer.

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
Explorer ,
Dec 17, 2022 Dec 17, 2022

Copy link to clipboard

Copied

YOU ARE AWESOME! A LIFE SAVER!!... THANKS A LOT FOR THE CORRECT RUNNING SCRIPT, IT DOES HELP ME FOR DAILY WORK... REALLY SIR, YOU ARE AWESOME!!

 

*sorry for the ALL CAPS text, I do really mean that, consider its a shoutout of my gratitude, Thanks! 😀

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 Expert ,
Dec 18, 2022 Dec 18, 2022

Copy link to clipboard

Copied

@DesainFreak2706 – You're welcome, thank you!

 

I have now updated the single script using the ALT/OPT key.

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
Explorer ,
Dec 18, 2022 Dec 18, 2022

Copy link to clipboard

Copied

the new codes single script are also works like a charmed... superb solution!

but if I'm using browse script from file menu, usually the "ALT"-keys will close the drop down menu, sometimes I do a little modification so altKEY changed into the ctrlKEY

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