Copy link to clipboard
Copied
Hi Everyone,
I know im not the first one to come here and ask a similar question/request about Photoshop Scripts for mockups, but i have been going all over discord and reddit without a solution and seems like i was looking at the wrong place.
I have been playing with ChatGPT to create a Photoshop script which seems to be almost there but still encountering errors.
My Objective for the script:
Once it is loaded, I want it to:
1. Open a window Modalt hat allows me to select 3 folders.
1 button for me to select the Folder/psd files i want to open for it to edit
1 button for me to select the Folder that contains the source IMGs to be used (Jpgs, pngs, etc)
1 button for me to select the destination folder where all the exported images are going to be saved
Here is an example of the window i created. You can suggest a better/easier/different idea as well. I just want it to be as simple as possible but to work to automate the most i can.
2. I would like the exported images to be named after the PSD document name and saved into a Subfolder that is named after each image. So if the file name of the Image is "A", i want the subfolder to be named A and so on for all images.
This is because the images are for an Online Store Product Listing. So, if the design is named A, it will have multiple angles, so i want all PSD files for Design "A" to be saved into a folder called "A" and the same for B, etc.
3. Once the script start running, I assume it will loop through all the PSD files that it will find on the folder i select. So Once the PSD file is open, I believe it needs to look for a specific layer. I thought it could search for an Smart Object Layer by name. In my case let's say i'll name the layer i need to edit "smart_object".
All my images are going to be the Same Size and Same DPI. Let me know if this must be changed/edited.
4. Finish.
Note: This is the code i made using chatGPT. Right now the code i had was working. It looped through the PSD files and everything but at the end, no image was exported. Probably some errors or something.
Any input greatly appreciated !!!
Copy link to clipboard
Copied
I'd suggest that you get the script working correctly first without any ScriptUI – adding a GUI adds extra complexity from the outset.
var theFolderOne = Folder.selectDialog ("Select the folder containing the PSD templates:");
var theFolderTwo = Folder.selectDialog ("Select the folder containing the product images:");
var theFolderThree = Folder.selectDialog ("Select the folder to save the combined images to:");
You would likely wish to use more robust code so that if a folder selection is cancelled, the script is terminated.
Copy link to clipboard
Copied
Hi Stephen
Thanks for reaching out! Appreciated.
Can you suggest a different idea?
honestly, that code was not made by me but by chatGPT so i would rather not touch it and start fresh. Was thinking maybe you could provide an alternative ? thanks!
Copy link to clipboard
Copied
Well there are so many smart object mockup templates on the forum, they are different as each user has unique use cases.
But if you don't know how to script, then it is going to be tough.
You could try something more generic:
https://github.com/MarshySwamp/JJMack-Archive (the Photo Collage Toolkit has two smart object scripts)
P.S. Smart objects add complexity and other overheads, so you might be able to use one of the collage scripts instead.
Copy link to clipboard
Copied
I understand. Thx, I took a look at it but there are many solutions that some i dont really need and others are quite complex. 🙂
Maybe you can help me troubleshoot what i am working on? I think it is fixing it, but now it says this error.
Im fixing the code with ChatGPT and its much cleaner now, but now not sure about this error.
How can i fix it?
There is a smart_object layer with this name and the images trying to be placed inside can indeed be placed inside.
Copy link to clipboard
Copied
It is hard for me to troubleshoot hundreds of lines of unknown code. The debugger shows no errors, so the code works but is incorrect in that it produces no result. I didn't see any code in there to open the smart object layer content and replace it.
It would likely be quicker for me to re-build this from scratch than to try to fix it. Both would take hours.
Copy link to clipboard
Copied
First, I'd point out that there is already a Photoshop plugin that does basically exactly what you're trying to do with your script: The Batch-Replace Smart Objects plugin has a panel/window in Photoshop where you can specify the PSD document you want to use, the input folder (which contains your images), and the output folder you want to save the final images to. Then you can just save your operations + run them as needed with one click. This could be a classic case of trying to reinvent the wheel and painstakingly write your own complex code to do something that an existing software solution already does effectively.
If you want to do this via scripting instead of a plugin, first off, to solve the problem you're having with it not exporting correctly, I'd first check that the code doesn't require the Smart Object to be the active/selected layer in the document. Second, I would also check to see if there aren't multiple Smart Objects in the document -- that could cause the code to fail if there's a condition that runs the code only if there's just one Smart Object.
Third, your error popup screenshoot seems to tell you exactly what the problem line of code is: "smartObject.place is not a function". Try modifying that section to better align with other scripts that batch-replace Smart Objects via .jsx code, and your solution could be there. While I can't recall the exact .jsx command I've used to replace Smart Objects in my scripts, I am almost certain smartObject.place was not included in there. I'm pretty sure it's a different command. (Check the Adobe Scripting guide I link to below to try to find the correct .jsx code for that.)
I would also point out -- if you go the scripting route, it might be better to just not even HAVE a window that pops up and requires you to manually specify the input folder/output folder/PSD document each time. Since your goal is to automate this process, could you just standardize your workflow + hardcode the PSD documents + folderpaths into the script -- then be able to just run the script and have it do this all for you? Why do more manual work then is required?
Speaking of reinventing the wheel, I have also seen similar scripts that may be close to what you're trying to accomplish posted here on the Adobe Community forums. Search through some of the threads to see if you can't find a similar script. Then you might just need to make a few minor tweaks to get it working for this workflow.
If that doesn't work, check this Adobe Scripting Guide to see if you can find the answers you're looking for there. I've found ChatGPT to be quite unreliable when it comes to writing Photoshop scripts, so solving this problem via scripting may require you going old school + reading some documentation to find the solutions you're looking for.