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

How to specify smart objects for image replacement by automatic processing

Community Beginner ,
Jan 05, 2020 Jan 05, 2020

Image> Variable> Definition

 

Then, when replacing the image, the smart object will no longer be the target of the image replacement. I want to perform batch image replacement with csv after giving the angle and scale to the replacement image. Is there any way or JSX to do this?

TOPICS
Actions and scripting , Windows
4.8K
Translate
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 , Jan 05, 2020 Jan 05, 2020

You can most likely use scriptlistener to get the code to replace a smartobject's content then create a looped script to run through all your files or csv entries to replace the images and apply the angles.

Translate
Community Expert , Jan 05, 2020 Jan 05, 2020

You would need to write a script that would work like Adobe's Data Driven graphics. That supports Smart object layers and come up with some way the define smart object layers as  a variable.  Photoshop variable only support three types of variable layer.  Text  layers for replacement, normal pixels layers for image replacement.  And Layers that you can control their visibility. 

 

Data Driven Graphics does not support replacing Smart Object layers content.  With Data driven graphics you can only

...
Translate
Adobe
Community Expert ,
Jan 05, 2020 Jan 05, 2020

You can most likely use scriptlistener to get the code to replace a smartobject's content then create a looped script to run through all your files or csv entries to replace the images and apply the angles.

Translate
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 ,
Jan 05, 2020 Jan 05, 2020
Thank you for the advice. I'll try that way!

 

Translate
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 ,
Jan 05, 2020 Jan 05, 2020

You would need to write a script that would work like Adobe's Data Driven graphics. That supports Smart object layers and come up with some way the define smart object layers as  a variable.  Photoshop variable only support three types of variable layer.  Text  layers for replacement, normal pixels layers for image replacement.  And Layers that you can control their visibility. 

 

Data Driven Graphics does not support replacing Smart Object layers content.  With Data driven graphics you can only control smart object layer visibility. 

 

There are also Problem replacing Smart Object Layer contents  using Photoshop Scripting. There are two ways to do it.

 

One is to use Photoshop Feature Layer>Smart Objects>Replace Content.  The replacement file must exactly like the object in the template Smart Object layer. exactly  the same size, aspect ratio and print resolution.  For the Smart Object Layers associated Layer Transform is not changed or updated when the object content is replaced. 

 

Two if the replacement files are not the correct size, aspect ratio and print resolution.  You can use Photoshop's feature to open Smart Object Layers Object.  Then you can fit the replacement file into the existing object. You can not change the size of the object for the associated smart object layer layer's transform is not updated.  There is an additional problem because all smart objects will not be opened in Photoshop.  Placed vector files object will open in a vector application like AI.  And place  a RAW file or RAW file opened as a smart object layer will open in ACR  the script would lose control and not be able do the replacement.  The Script would need to bypass replacing vector objects and RAW objects if the template has those kind of objects. 

 

I also do not know if a Script can see which layers are Photoshop defined variables.  You may need a different method to define replacement layers. Like a some Layer naming convention in you template psd files.

 

If you want to change rotation  you would need to edit the smart object layer associated transform which currently can have rotation and warping settings. I would not know how to automate modified  an existing transform that has sizing warping and rotation.  Photoshop's Data Driven Graphics does not support inage rotatioj

 

Script can read and write CSV file.  I will be quite a task to develop such a jsx.

JJMack
Translate
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 ,
Jan 05, 2020 Jan 05, 2020

I learned very much. It's deep! I want to deepen my understanding!

Translate
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
Mentor ,
Jan 06, 2020 Jan 06, 2020

In some cases using the action manager, you can edit the contents of a smart object without opening it (in particular, access the layers inside it) - unsmart script of  Jaroslav Bereza

Also in the latest versions of Photoshop, a useful feature appeared - convert smart object to layers (a group is created in the document with the name of the smart object and its contents in the form of layers) - this can be done in your script in one line:

 

executeAction( stringIDToTypeID( "placedLayerConvertToLayers" ))

 

You can perform all necessary conversions and then re-save this group as a smart object:

 

executeAction( stringIDToTypeID( "newPlacedLayer" ))

 

Translate
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 ,
Jan 06, 2020 Jan 06, 2020

That seems replace the smart object layer with other layers and it can not had distortion and smart filters. Therefore, Replace Content and Opening and Editing the object will work better.  For on one of mains reason for using smart objects in templates is they have support  distorting images via the smart object  layer's associated transform witch includes sizing, rotation, perspective and warping.  And adjustment with smart filters. Its discription even confuses me.

image.png

 

Also Photoshop placeLayerConvertToLayers will be like rasterize layer if you want to keep the visual effects of warping and filtering or remove all warping and filtering.   You can not convert back to a simular smart object layer.

 

Capture.jpg

JJMack
Translate
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
Mentor ,
Jan 06, 2020 Jan 06, 2020
LATEST

I looked at the Jaroslav Bereza code and saw that it is possible to use a different approach, compatible with earlier versions of Photoshop, which may be of interest to the author of the topic. This can be briefly described by the following set of menu commands:

Convert Smart Object to Linked file and save it in temp dir (if it has graphical content, that can be edited in the Photoshop environment, otherwise (if it is, for example, a vector file from AI), this command will be unavailable) -> open this file in Photoshop and work with its content as with a regular document -> close & save -> run "Embed linked" command in parent document  -> delete linked file

 

In this case, there will be no problems with the transformation and effects and at the same time we can control the contents of the smart object (without replacing it completely)

 

(I think that it is worth voicing any working solution, maybe it will be useful to someone)

Translate
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