Skip to main content
Participating Frequently
November 19, 2015
Question

How to replace an image in a mockup by script / Remplacer image dans un script

  • November 19, 2015
  • 2 replies
  • 4048 views

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!!!!!

This topic has been closed for replies.

2 replies

Participating Frequently
November 20, 2015

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);

Participating Frequently
November 20, 2015

Merci. Je vais continuer de voir avec la méthode précédente car je ne vois pas au ajouter les lignes de code...

JJMack
Community Expert
November 20, 2015

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.

JJMack
Participating Frequently
November 20, 2015

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.....

JJMack
Community Expert
November 23, 2015

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.....


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.

.

JJMack