Copy link to clipboard
Copied
Hi everyone,
My knowledge of coding is unfortunately very minimal, and I've been having a really hard time for the better part of the day trying to figure out how to do this following other answers I've seen on here.
I have a mock up PSD that has 2 smart objects within it and I have 2 folders each with an equal number of images in them.
I need a script that can replace the first smart object with an image from the first folder and the second smart object with an image from the second folder and then export the whole thing. There's about 700~ images in both of the folders so I need it to run through all of them if possible.
As an example it would export like this.
Fortunately the images have mirrored names across the folders (i.e image1-side-a and image1-side-b) so I don't need the script to look for filenames or anything like that.
Any help would be extremely appreciated.
@NelNelD – I have updated the code to a 1.1 version, the lower smart object layer is now removed.
EDIT: Let me know how it goes. I have now updated to a 1.2 version so that all layers in the smart object are removed, except the top layer.
I have updated the code to version 1.3 to remove any photoshop:DocumentAncestors metadata build-up in the smart objects and or main PSD file which may bloat the file size after multiple uses.
Here is the revised script for your specific template and assets:
/*
Video Game Smart Object Layer Replacements to PNG.jsx
Version 1.0 - 22nd June 2024, Stephen Marsh
Based on:
https://community.adobe.com/t5/photoshop-ecosystem-discussions/batch-script-to-replace-2-smart-objects-and-save-the-final-image/m-p/13728400
*/
#target photoshop
(function () {
try {
var selectFile = File.openDialog("Select the template file:");
open(selectFile);
...
Copy link to clipboard
Copied
The ppi value of the files that place smaller was 300ppi (I resized them with IrfanView).
Thanks to you, I realized the Box Front images must be 960x1357 and 72ppi, and the Box Spines images must be 231x1357 and 73ppi too, to work with your script.
I can easily do that with IrfanView or by placing all images in the smart object layer, resize, and batch export them with photoshop.
Thanks again to make me save a lot of time. Let me know how can i invite you a beer 🙂
Copy link to clipboard
Copied
Thanks to you, I realized the Box Front images must be 960x1357 and 72ppi, and the Box Spines images must be 231x1357 and 73ppi too, to work with your script.
By @ci2own
It's not just my script, if you were doing this manually you'd have the same issue, it's how smart object replacement works.
Copy link to clipboard
Copied
And also i realized doing some tests, the example images fits perfect on the result box, because i exported them from the same template, but when image size don't match the one in the smart object, it doesn't addapt it automatically:
By @ci2own
This is how smart objects work. You need to ensure that all assets are as follows:
Spine replacement image = 231 x 1357px @ 72ppi
Box Front replacement image = 960 x 1357 @ 72ppi