Script photoshop/illustrator

Community Beginner ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Hello,

I would like to make a Photoshop script to open a folder with images that I want to open with a dynamic vector layer (which directs to Illustrator).
Is this possible?

Thank you.

TOPICS
Windows

Views

138

Likes

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
Adobe Community Professional ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Do you mean a Vector Smart Object? 

Opening the SO via Script should not be a problem, but do you want the Script to perform operations in Illustrator after that? 

Likes

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 ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

No I don't want the script to perform any action on Illustrator but only to open to Illustrator

Thanks

Likes

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
Adobe Community Professional ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Then 

openSmartObject();
////// open smart object //////
function openSmartObject () {
    var idplacedLayerEditContents = stringIDToTypeID( "placedLayerEditContents" );
    var desc2 = new ActionDescriptor();
    executeAction( idplacedLayerEditContents, desc2, DialogModes.NO );
    return activeDocument;
    };

schould suffice (provided the SO is the active Layer). 

Likes

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 ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

ok great thanks !
How do I run it?
I saved it in .js and then what are the manipulations to do on photoshop ? thank you very much

Likes

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
Adobe Community Professional ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied


@Thomas25199145gknj wrote:

ok great thanks !
How do I run it?
I saved it in .js and then what are the manipulations to do on photoshop ? thank you very much


 

  1. Copy the code text to the clipboard
  2. Open a new blank file in a plain-text editor (not in a word processor)
  3. Paste the code in
  4. Save the text file as .txt
  5. Rename the file extension from .txt to .jsx
  6. Install or browse to the .jsx file to run:

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html#Photoshop

 

Likes

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 ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Thank you for everything, 

But at first I would like to know how to import an image from illustrator to photoshop and to transform it into a smart object. 

Then, I would like to know if it is possible, with a script, to do the same thing with a bunch of images (which would be in the same folder), and to obtain several .psd, with one smart object each time in each .psd. 
Do you think that it is possible ? 

Thank you very much for everything ! 

Likes

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
Adobe Community Professional ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

I think it is time for you to provide a meaningful explanation of the intended process with screenshots to illustrate both the file structure and the layer structure. 

Likes

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 ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

Thank's for your patience !
Here is an example :
 
I have a bunch of images (JPEG) in a folder (for example 5 here), that have almost the same name but not the same number.
 
folder.png
 
 
I would like to import them into photoshop as a smart object. (Usually, I have to open them in Illustrator, then paste them in phosothop to create the smart object that I can then work with).
 
images.png
 
The idea would be to create a script to get one PSD per image, and each image would be a Smart Object (that could be opened in Illustrator).
I was wondering if we could do that in a batch, and obtain something like that :
 
001_DOWN_001_POS.JPEG becomes 001_DOWN_001_POS.PSD
001_DOWN_002_POS.JPEG becomes 001_DOWN_002_POS.PSD
etc....
 
I wanted to make it automatic, and to create a script that would allow me to :
 
- Create the PSD with the Smart Object inside (and avoid the step where I have to copy and paste from illustrator)
- Give the same name to my PSD (the same that was on the JPEG)
- And save it in a folder that I could chose.
 
If you could help me with that, that would be amazing ! 

Thank you 

Likes

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
Adobe Community Professional ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

So you just want to place separate JPG files as individual smart object layers in a Photoshop document?


None of these files are vector or .ai or .pdf files? 

Illustrator has no real relevance in this process.

Likes

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
Adobe Community Professional ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

As @Stephen_A_Marsh already pointed out there seems to be no reason to involve Illustrator in this process.  

What are you trying to achieve by dragging the jpgs through a vector application in this process? 

Likes

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
Adobe Community Professional ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

@Thomas25199145gknj – I am not sure if this is what you want or not. The following script will stack a folder of supported filetypes as linked smart objects. It is easy to change the setting from linked to embedded if that is how you wish to work. The colour mode and bit depth are based off the first file opened. Supported filetype extensions include: jpg/jpeg, tif/tiff, png, psd, psb & gif

 

/*
Stacker - Place Linked.jsx
Stephen Marsh, v1.0
*/

#target photoshop

if (app.documents.length === 0) {
    (function () {
        var savedDisplayDialogs = app.displayDialogs;
        app.displayDialogs = DialogModes.NO;
        var origUnits = app.preferences.rulerUnits;
        app.preferences.rulerUnits = Units.PIXELS;

        var inputFolder = Folder.selectDialog('Please select the input folder:');
        if (inputFolder === null) {
            app.beep();
            return;
        }

        var inputFiles = inputFolder.getFiles(/\.(jpg|jpeg|tif|tiff|png|psd|psb|gif)$/i);
        // inputFiles.sort().reverse;
        inputFiles.sort();

        app.displayDialogs = DialogModes.NO;

        var baseDoc = open(inputFiles[0]);
        baseDoc = activeDocument;
        baseDoc.duplicate("Stacker", false);
        baseDoc.close(SaveOptions.DONOTSAVECHANGES);

        for (var i = 0; i < inputFiles.length; i++) {
            placeFile(new File(inputFiles[i]), true, 0, 0);
            //align2SelectAll('AdCH');
            //align2SelectAll('AdCV');
        }

        activeDocument.activeLayer = activeDocument.backgroundLayer;
        activeDocument.activeLayer.remove();

        //app.runMenuItem(stringIDToTypeID("selectAllLayers"));
        //reverseLayerStack();
        app.beep();
        alert(inputFiles.length + ' files stacked!');
        app.displayDialogs = savedDisplayDialogs;
        app.preferences.rulerUnits = origUnits;


        // Functions

        function placeFile(null2, linked, horizontal, vertical) {
            var s2t = function (s) {
                return app.stringIDToTypeID(s);
            };
            var AD = new ActionDescriptor();
            AD.putInteger(s2t("ID"), 1);
            AD.putPath(s2t("null"), null2);
            AD.putBoolean(s2t("linked"), linked); // false for embedded
            AD.putEnumerated(s2t("freeTransformCenterState"), s2t("quadCenterState"), s2t("QCSAverage"));
            AD.putUnitDouble(s2t("horizontal"), s2t("pixelsUnit"), horizontal);
            AD.putUnitDouble(s2t("vertical"), s2t("pixelsUnit"), vertical);
            AD.putObject(s2t("offset"), s2t("offset"), AD);
            executeAction(s2t("placeEvent"), AD, DialogModes.NO);
        }

        function reverseLayerStack() {
            var idreverse = stringIDToTypeID("reverse");
            var desc4653 = new ActionDescriptor();
            var idnull = stringIDToTypeID("null");
            var ref2335 = new ActionReference();
            var idlayer = stringIDToTypeID("layer");
            var idordinal = stringIDToTypeID("ordinal");
            var idtargetEnum = stringIDToTypeID("targetEnum");
            ref2335.putEnumerated(idlayer, idordinal, idtargetEnum);
            desc4653.putReference(idnull, ref2335);
            executeAction(idreverse, desc4653, DialogModes.NO);
        }

        function align2SelectAll(method) {
            /*
            AdLf = Align Left
            AdRg = Align Right
            AdCH = Align Centre Horizontal
            AdTp = Align Top
            AdBt = Align Bottom
            AdCV = Align Centre Vertical
            */
            app.activeDocument.selection.selectAll();
            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) {}
            app.activeDocument.selection.deselect();
        }
    })();

} else {
    alert('Please close all open files before running this script...');
} 

 

Likes

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
Adobe Community Professional ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied


@Thomas25199145gknj wrote:

 

I would like to make a Photoshop script to...



Does this mean that you have some knowledge/ability to script and just need some pointers to get you started or to overcome points where you have stalled?

 

Or does this mean that you can't script and want someone to write the script for you?

 

The replies would be different in each case.

Likes

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 ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

We don't have ability to write a script by ourselves, we only have notions in js, but it is not enough to solve the problem 😕
Thanks 


Likes

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
Adobe Community Professional ,
Jul 11, 2022 Jul 11, 2022

Copy link to clipboard

Copied

This would offer a dialog for file selection, open the selected files, duplicate the lowest layer, convert it to a smart object, save the image as a psd and open the smart object. 

// 2022, use it at your own risk;
var theSourceFiles = selectFile (true);
if (theSourceFiles != null) {
    for (var m = 0; m < theSourceFiles.length; m++) {
        var thisFile = app.open(File(theSourceFiles[m]));
        var theDup = thisFile.layers[thisFile.layers.length - 1].duplicate();
        thisFile.activeLayer = theDup;
        theDup.name = thisFile.name;
        convertToSmartObject();
        saveAsPsd (thisFile, thisFile.path, thisFile.name.match(/(.*)\.[^\.]+$/)[1], false);
        openSmartObject();
    };
};
////// select file //////
function selectFile (multi) {
    if (multi == true) {var theString = "please select files"}
    else {var theString = "please select one file"};
    if ($.os.search(/windows/i) != -1) {var theFiles = File.openDialog (theString, '*.jpg;*.tif;*.png', multi)}
    else {var theFiles = File.openDialog (theString, getFiles, multi)};
    ////// filter files  for mac //////
    function getFiles (theFile) {
        if (theFile.name.match(/\.(jpg|tif|psd|png)$/i) || theFile.constructor.name == "Folder") {
            return true
            };
        };
    return theFiles
    };
////// open smart object //////
function openSmartObject () {
    var idplacedLayerEditContents = stringIDToTypeID( "placedLayerEditContents" );
    var desc2 = new ActionDescriptor();
    executeAction( idplacedLayerEditContents, desc2, DialogModes.NO );
    return activeDocument;
    };
////// convert to smart object //////
function convertToSmartObject () {
var desc108 = new ActionDescriptor();
var ref77 = new ActionReference();
ref77.putEnumerated( charIDToTypeID( "Mn  " ), charIDToTypeID( "MnIt" ), stringIDToTypeID( "newPlacedLayer" ) );
desc108.putReference( charIDToTypeID( "null" ), ref77 );
executeAction( charIDToTypeID( "slct" ), desc108, DialogModes.NO );
};
////// save psd //////
function saveAsPsd (thedoc, docPath, basename, overwrite) {
// check for existing file
    if (overwrite == false && File(docPath+'/'+basename+'.psd').exists == true) {
        var theConfirm = confirm("overwrite existing file");
        if (theConfirm == false) {return false}
        };
// make copy and save
    if (app.documents.length > 0) {
    try {
    saveOpts = new PhotoshopSaveOptions();
    saveOpts.embedColorProfile = true;
    saveOpts.alphaChannels = true;
    saveOpts.layers = true;
    saveOpts.spotColors = true;
    thedoc.saveAs((new File(docPath+'/'+basename+'.psd')),saveOpts,false);
    }
    catch (e) {docName+" failed"}
    }
    };

 

Likes

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 ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

Hello,

Thank you very much for your answer but I think that unfortunately what I want to do is difficult.

The action of the script that you sent me is good ! I thank you for it 🙂

But dynamic object which is created in photoshop is not a Vector smart Object. I think that it is necessary to create a script which gathers actions on the two software: (illustrator and photoshop).

I show you the actions that I have to realize via screen captures:

 

1) My images
folder.png

2) I transfer all my images into Illustrator in order to have a Vector object.
I'm sorry I haven't made the link between the two programs clearer since the beginning of our discussion.
Thank you very much.

  I copy/paste to photoshop

images.png

3) Finally I double click on Vectorsmartobject to modify the image on illustrator.





Likes

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
Adobe Community Professional ,
Jul 12, 2022 Jul 12, 2022

Copy link to clipboard

Copied

LATEST

But the Vector Smart Object contains a pixel image – to what end? 

 

One can address Illustrator and Photoshop in one Script by using BridgeTalk. 

Likes

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