How to replace an image in a mockup by script / Remplacer image dans un script
Copy link to clipboard
Copied
hi, fisrt, sorry for my english, I am french. I am going to try to be understood easily...
I have a mockup file (pillow-mockup.psd). As you can see on my picture white and yellow. (Here is the mockup to download: Behance
I have to change the mockup using 1000 images (example : image1.jpeg, image2.jpeg) . As on my picture with pingoiuin.
I can do it but my final file has always the same name : pillowmockup instead image1, image2
What I did in my script
-I open pillow-mockup.psd on photoshop
-I open image.jpg on photoshop
- I move image1.jpg on the file mockup.psd
I would like to have my final file called image1 (or better : image1-mock) and not pillow-mockup
How to do ?
Thanks...
----------------------------------------------------------------------------------------
Bonjour,
J'ai un fichier "mockup.psd" avec différents calques. Un oreiller avec un logo.
Je dois utiliser un script pour changer le logo en utilisant 1 000 images différentes à chaque fois.
J'ai réussi en glissant une image sur le calque mockup.psd à remplacer le logo de l'oreiller.
Le soucis, c'est que mon fichier final a le nom mockup.psd et que du coup je ne peux pas l'utiliser en script sinon les fichiers s'enregistrent avec le même nom...
Le top serait que le fichier prenne le nom de l'image glissée.
Exemple : je glisse image1.jpjeg sur mockup.psd, mon fichier final se nommerait : image1.psd ou image1.jpeg
Merci!!!!!
Explore related tutorials & articles
Copy link to clipboard
Copied
I know no French so your better them me I have to use English my native tong but I failed every English class I had to take in school.
It sounds like your doing the replacement and because your replacing the smart object layer's object the filename of the replacement is lost in the shuffle.
If you were to automate the process with a script. The script would have access to that filename and could name the file it save and include that name.
I do not have a script that replaced smart object layer's objects because all replacement need to be the same size and resolution as the original template object. I prefer to be able to handle and size image.
I created a template from your template that would work with my batch script. Because I do not use replace layer content I can not attach smart filter to image layers. I do place in images but would not know how to adjust a smart filter for the layer content. All my scripts can do is add layer styles to image layers. However a demo of my script will show you the a script would have no prone creating the file mane you would want.
Copy link to clipboard
Copied
hi,
Thanks very much for everything. (And your post about script to download : how do I insert my image into a template?)
I tried to manage all my layers to do like you. (I changed some names and the pillow.)
My problem is to succeed in creating the channel you called "image 1".
Could you explain me please ? Thanks for all.....
Copy link to clipboard
Copied
In your template if you Ctrl|CMD+click on your Pillow Layer's Layer Content Icon in the layers palette that will select the Pillow pixels. You then use menu Select>Save Selection,,, Then in the save selection dialog you save in the current document a new channel and name it "Image 1".
It would also be possible to eliminate your shadows layers. You could create a Layer Style the coul add those effects. You need the Pillow layer to blend in the pillow texture and shadows. If you downloaded my Photo Collage Toolkit you can add additional Layer Styles to the toolkit's preferences script. The script is use by all the Collage populating scripts.
If you look at the video you will see I used a layer that is 50% gray with a layer style to overlay an image layer and burn the NYFD logo into the image. In my template the color did not hav to be 50% gray for I set the fill to 0. The layer was as shape layer I rasterized to reduce the psd file size. Additionally you can Layer styles to image layers and text layer the script add populating the collage. Image can be stamped with the file name in on of 9 locations over the images. If the collage is being populates is a single image collage you can stamp the filename on the image or on the collage.
Copy link to clipboard
Copied
Thanks.
Ok for creating the channel.
I saved my template pillow.psd, managed the script "Batchoneimagecollage" with good folders but this is the result :
Selected Template file does not have the Required Photoshop Background Layer
Copy link to clipboard
Copied
Yes my scripts require a template to have a background layer. There are four requirements. It look like your template does but the script does not see the bottom layer is a Background layer???
var layers = activeDocument.layers;
activeDocument.activeLayer = layers[layers.length-1]; // Target Bottom Layer
if ( !activeDocument.activeLayer.isBackgroundLayer ) {
alert("Selected Template file does not have the Required Photoshop Background Layer");
} else { // Has Background
The Four Rules:
- Size the photo collage templates for the print size you want - width, height and print DPI resolution.
- Photo collage templates must have a Photoshop background layer. The contents of this layer can be anything.
- Photo collage templates must have alpha channels named "Image 1", "Image 2", ... "Image n".
- Photo collage templates layers above the background layers must provide transparent areas to let the images that will be placed below them show through.
Copy link to clipboard
Copied
Thanks.
Where do i use this ?
var layers = activeDocument.layers;
activeDocument.activeLayer = layers[layers.length-1]; // Target Bottom Layer
if ( !activeDocument.activeLayer.isBackgroundLayer ) {
alert("Selected Template file does not have the Required Photoshop Background Layer");
} else { // Has Background
Copy link to clipboard
Copied
That is code from my script where its start to process the template. The first thing the script does is to test the bottom layer to see that its a background layer that does not support transparency and can have no layers under it. With the background layer targeted the script is in position to start placing in your images. Are you sure you selected a template file to populate that has a Photoshop Background layer. The script tested the bottom layer of the template you pointed it at after opening it into Photoshop. It did not find the bottom layer was Photoshop's background layer. It was a normal layer, a smar object layer or some other layer type. Not the background layer.
Copy link to clipboard
Copied
Ok. I made a new background layer. Everything is allright. Thanks for all.
If I want my files in JPEG automatically.
Do you thing I should record manually my script (Save 72 DPI etc...) and after I use automation to apply to a folder.
Or
Modify the script I use to save in JPEG instead of PSD ?
Thanks.
Copy link to clipboard
Copied
The only scripts of mine that save files are the batch populating scripts. They can save jpeg files as well as PSD. The way the scripts are coded PSD will be saved you can additionally save jpeg files. My scripts are not save in binary so you can easily change how they work. If you do use the Batch scripts you could easily also improve their performance. Change them not the close the template up front. Still Populate a copy then after the populated copy is save close the copy instead of un-populating the copy create new fresh copy to populate the next collage. I may do that some time. I only hack at scripting and wanted to see if I would be able to process a populate collage well. I was not planing to actually batch populate template often so I did not care about performance. You can also speed up performance by toggling the pallets off before population the collages then toggle them back on when done populating. Photoshop will run much faster if it does not have to update visible pallets. The Batch scripts I make availble will always save PSD for they can easily be enhanced with Photoshop flat files would be hard to modify.
About 72 DPI the scripts do not chage the Template resolution., Read Rule number one again. If you want 1920px by 1080ps at 72DPI create that template.
- Size the photo collage templates for the print size you want - width, height and print DPI resolution.
My aim was to have Template design where they would be easy to create and easy to design template with. I started with five simple rules and was able to remove one and get it down to four rules that are not very restrictive. There are thing that I saw as not easy to automate like some image rotation and perspective transforms. That is why I always create layered document. Things like image tilting and perspective transforms must still be done manually.
Copy link to clipboard
Copied
Hi,
I didn't understand all what you told exactly. But the most important.
I succeeded in modifying the script and i adjusted quality From 8 to 10.
(else { SaveAsPSD( outputFile, true ); } ---> else { SaveAsJPEG( outputFile, true ); }
But the result is not as good as photoshop function 'save for web'.
Is there a possibility to tell the script to use "save for web, quality 60" which is really much better.
Thanks for your answer. I have to use your script on 1 000 files.....
Copy link to clipboard
Copied
Ok I made a script. Thanks !!!
Copy link to clipboard
Copied
For a 1000 images start the script and take a coffee break. Hide the palettes before you start the batch. Changing the script operation from un-populate to using a new duplicate template will shorten the script's run time. To use save for web you need to change the save code to export document. You would need to use the exportDocument method with export options save for web or Action manager code for Save for web Adobe Scriptlistener Plug-in records.
.
Copy link to clipboard
Copied
Bonjour
Plutot que d utiliser le traitement par lot de Photoshop tu devrais le faire dans ton script avec la methode getFiles() - ainsi tu peux recuperer le nom des images ouvertes et l utiliser pour sauvegarder le psd.
//Nom du fichier
nomFichier = docRef.name;
nomFichier = nomFichier.split(".");
nomFichier = nomFichier[0];
alert(nomFichier);
Copy link to clipboard
Copied
Merci. Je vais continuer de voir avec la méthode précédente car je ne vois pas au ajouter les lignes de code...

