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

Batch Mockup Multiple Dimensions

Explorer ,
Jun 22, 2021 Jun 22, 2021

Hello i got a mockup file like this. Im trying to batch process my designs with this mockup.

defaulttqp5mw77uuzf_1-1624359811808.png

I archive my designs like this

defaulttqp5mw77uuzf_2-1624359894119.png

defaulttqp5mw77uuzf_3-1624359921826.png

 

i want to write script to crop my pdf file like 

defaulttqp5mw77uuzf_4-1624359977218.png

and place it into smart layer

defaulttqp5mw77uuzf_6-1624360286260.png

 

fit to canvas and align to right

defaulttqp5mw77uuzf_8-1624360341536.png

Save smart object layer . psd so mockup generates photo

defaulttqp5mw77uuzf_9-1624360381742.png

save this file photoname-mockup-righthand.jpeg

select all layers than flip horizontal

defaulttqp5mw77uuzf_10-1624360487516.png

edit smart object layer

defaulttqp5mw77uuzf_11-1624360521985.png

select all layers than flip horizontal

select all layers and align it to left.

defaulttqp5mw77uuzf_12-1624360600790.png

save smart object psd so mockup generates new photo

defaulttqp5mw77uuzf_13-1624360641351.png

save this file photoname-mockup-lefthand.jpeg

 

Can anyone help me to write script to batch process my designs to mockup photos.

I have no javascript knowledge*

Sorry for my bad english.

Thank you.

 

 

TOPICS
Actions and scripting , Windows
4.2K
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 1 Correct answer

Community Expert , Jun 28, 2021 Jun 28, 2021

With below code I get these resulting images for »Mug Right.psd«: 

Mug Right_1.jpgMug Right_2.jpgMug Right_3.jpgMug Right_4.jpgMug Right_5.jpg

// 2020, use it at your own risk;
if (app.documents.length > 0) {main()};
function main () {
    try {
        var myDocument = activeDocument;
        var theName = myDocument.name.match(/(.*)\.[^\.]+$/)[1];
        var thePath = myDocument.path;
        var theFiles = selectFile (true);
        var theLayers = collectLayersByName ("Your Design Here");
        selectLayerByID(theLayers[0][2],false);
        var theSO = openSmar
...
Translate
Adobe
Explorer ,
Sep 07, 2021 Sep 07, 2021

Can someone help me edit this code so it saves on PDF format instead of jpeg.

Thank you.

 

 

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 ,
Sep 07, 2021 Sep 07, 2021

I have no idea of what pdf save option you want to use. Something like this may save a pdf with default options.

 

function SavePDF(thePath, theName, theNewName){ 
   saveFile = new File(thePath + "/" + theName + "_" + theNewName + ".pdf");
   pdfSaveOptions = new PDFSaveOptions(); 
   activeDocument.saveAs(saveFile, pdfSaveOptions, true, Extension.LOWERCASE); 
};

 

 

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
Explorer ,
Sep 07, 2021 Sep 07, 2021

defaulttqp5mw77uuzf_4-1629313982241.pngdefaulttqp5mw77uuzf_5-1629314059659.png

Compression => None

Embed Page Thumbnails

Optimize for fast web preview

Thank you so much

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 ,
Sep 07, 2021 Sep 07, 2021

These are the options that are documented set those you want to use.

image.png

image.png

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
Explorer ,
Sep 29, 2021 Sep 29, 2021

 

// 2020, use it at your own risk;
if (app.documents.length > 0) {main()};
function main () {
    try {
        var myDocument = activeDocument;
        var theName = myDocument.name.match(/(.*)\.[^\.]+$/)[1];
        var thePath = myDocument.path;
        var theFiles = selectFile (true);
        var theLayers = collectLayersByName ("Your Design Here");
        selectLayerByID(theLayers[0][2],false);
        var theSO = openSmartObject();
        for (var m = 0; m < theFiles.length; m++) {
            var thisOne = theFiles[m];
            replaceContents (thisOne, theSO.activeLayer);
            theSO.save();
            activeDocument = myDocument;
            savePDF(thePath, theName, new File (thisOne).name.match(/(.*)\.[^\.]+$/)[1]);
            activeDocument = theSO;
        };
        theSO.close();
    }
    catch (e) {alert ("something is wrong")}
};
////// open smart object //////
function openSmartObject () {
    var idplacedLayerEditContents = stringIDToTypeID( "placedLayerEditContents" );
    var desc2 = new ActionDescriptor();
    executeAction( idplacedLayerEditContents, desc2, DialogModes.NO );
    return activeDocument;
    };
////// replace contents //////
function replaceContents (newFile, theSO) {
    app.activeDocument.activeLayer = theSO;
    // =======================================================
    var idplacedLayerReplaceContents = stringIDToTypeID( "placedLayerReplaceContents" );
    var desc3 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
    desc3.putPath( idnull, new File( newFile ) );
    var idPgNm = charIDToTypeID( "PgNm" );
    desc3.putInteger( idPgNm, 1 );
    executeAction( idplacedLayerReplaceContents, desc3, DialogModes.NO );
    return app.activeDocument.activeLayer
    };
////// select files //////
function selectFile (multi) {
if (multi == true) {var theString = "please select files"}
else {var theString = "please select one file"};
if ($.os.search(/windows/i) != -1) {var theFiles = File.openDialog (theString, '*.jpg;*.tif;*.psd;*.pdf;*.ai', multi)}
else {var theFiles = File.openDialog (theString, getFiles, multi)};
////// filter files  for mac //////
function getFiles (theFile) {
    if (theFile.name.match(/\.(jpg|tif|psd|pdf|ai)$/i) || theFile.constructor.name == "Folder") {
        return true
        };
	};
return theFiles
};
////// save a jpg //////
function SavePDF(thePath, theName, theNewName){ 
    saveFile = new File(thePath + "/" + theName + "_" + theNewName + ".pdf");
    pdfSaveOptions = new PDFSaveOptions(); 
    activeDocument.saveAs((new File(thePath+"/"+theName+"_"+theNewName+".pdf")),pdfSaveOptions,true);
};

////// collect layers with certain name //////
function collectLayersByName (aName) {
    // the file;
    var myDocument = app.activeDocument;
    // get number of layers;
    var ref = new ActionReference();
    ref.putProperty(stringIDToTypeID('property'), stringIDToTypeID('numberOfLayers'));
    ref.putEnumerated( charIDToTypeID("Dcmn"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
    var applicationDesc = executeActionGet(ref);
    var theNumber = applicationDesc.getInteger(stringIDToTypeID("numberOfLayers"));
    // process the layers;
    var theLayers = new Array;
    for (var m = 0; m <= theNumber; m++) {
    try {
    var ref = new ActionReference();
    ref.putIndex( charIDToTypeID( "Lyr " ), m);
    var layerDesc = executeActionGet(ref);
    var layerSet = typeIDToStringID(layerDesc.getEnumerationValue(stringIDToTypeID("layerSection")));
    var isBackground = layerDesc.getBoolean(stringIDToTypeID("background"));
    // if group collect values;
    if (layerSet != "layerSectionEnd" /*&& layerSet != "layerSectionStart" && isBackground != true*/) {
    var theName = layerDesc.getString(stringIDToTypeID('name'));
    var theID = layerDesc.getInteger(stringIDToTypeID('layerID'));
    var theIndex = layerDesc.getInteger(stringIDToTypeID('itemIndex'));
    if (theName == aName) {theLayers.push([theName, theIndex, theID])}
    };
    }
    catch (e) {};
    };
    return theLayers
    };
////// based on code by mike hale, via paul riggott //////
function selectLayerByID(id,add){ 
    add = undefined ? add = false:add 
    var ref = new ActionReference();
        ref.putIdentifier(charIDToTypeID("Lyr "), id);
        var desc = new ActionDescriptor();
        desc.putReference(charIDToTypeID("null"), ref );
           if(add) desc.putEnumerated( stringIDToTypeID( "selectionModifier" ), stringIDToTypeID( "selectionModifierType" ), stringIDToTypeID( "addToSelection" ) ); 
          desc.putBoolean( charIDToTypeID( "MkVs" ), false ); 
       try{
        executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );
    }catch(e){
    alert(e.message); 
    }
    };

 

Could anyone help me fix this code ? it does not work. manually changed jpeg save options to pdf. For some reason it crashes photoshop.

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
LEGEND ,
Sep 29, 2021 Sep 29, 2021

You need to run it in a debugger so you can see what line fails. This script does several things. What have you tried ths far for troubleshooting?

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 ,
Sep 29, 2021 Sep 29, 2021

I see no crash  I get an erroe for there is no savePDF function. I the scipt I  see line 17

savePDF(thePath, theName, new File (thisOne).name.match(/(.*)\.[^\.]+$/)[1]);

But in the script  I see a function

function SavePDF(thePath, theName, theNewName){

 

There is also a problen with line 14 I had to comment out that line 

replaceContents (thisOne, theSO.activeLayer);

you opened the smart object file for edit if it was a Photoshop object.   The Active  in the open smart object is more likely not a Smart Object layer that cans have its contents replace.  The Replace content statement will fail for replace content is not available for the activate layer type in the object file You would edited the selected files onto the object.  If you want to repeatedly replace the smart object do not open the smart object replace its content.

 

If you look at my mockup populating script you wile see both ways to update smart object,  Replace content require the replacement file to be the correct size replacements. Where if the replacement are not the correct size the script can open the objects  and  edit the replacement file into the object file document  when the object is saved Photoshop will replace the content of the smart object  in the template. 

 

You also need to look before you use openSmartObject  For if the Smart object is a RAW or Vector Object.  the The  object will open in ACR or AI  your script will not be able to edit the object.

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 Expert ,
Jul 03, 2021 Jul 03, 2021

I looked for a free Coffee Mug 3D nodel that you may bat ablet to coat the surface with a design like your london panorama.   

 

image.png

image.png

All the ones I found outer surfaces uv were complex.   It would not be easy to place a panaramra images onto the cups outer surface.

cupa.gif

image.pngimage.png

 

 

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 Expert ,
Jul 03, 2021 Jul 03, 2021

I did find a Free 3D Coffee Mug model I can batch populate in Photoshop

LondonStretchedCup-CpffeeMug-3DCoffeMug512.gif

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
Explorer ,
Jul 04, 2021 Jul 04, 2021

Can you share a guide so i can use it. It looks aweasome

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 ,
Jul 04, 2021 Jul 04, 2021

I'm not completely happy with the model for the way the model works the surface seems to needs a distorted image that has been stretched tall  when it applied 3D feature distorted it back down. The script I wrote just replaces top surface in a 3D layer named  3Dtexture.   I have never made the script public,  There are also Issues  in Photoshop 2021 3D the models does not work properly I just try to close the document Photoshop 22.4.2 terminates unexpectedly. I have to use Photoshop 2020 version 21.2.9.  3D models surfaces can be complex and the UV fold out all over the canvas.  I have only used easy geometric models the Surface have flat areas I populated with images.  I create Photo Collage or Mockup  templates and use my batch populating scripts to populate these  templates to create replacement surfaces   for the 3D model template. So its two batch Jobs to populate the 3D templates which also has a video time line the script  save a populated PSD and an MP4 video and optionally a jpeg.

 

https://www.turbosquid.com/Download/457218_2811792 

 

So it a complex process. The 3D template is complex to create and you also need to create  a collage or mockup template  to build surfaces for  the 3D template.

Capture.jpg

image.png

london.gif

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 Expert ,
Sep 07, 2021 Sep 07, 2021

Hello, I have to commend Christoph and JJ here, as they provide tremendous free help for what seems to be a commercial endeavour...

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
Explorer ,
Jul 27, 2022 Jul 27, 2022
LATEST

 

Now Using Bulk Mockups Filler, Automatically Replace Smart Object Content Perfectly in Any Adobe Photoshop Version.

Unlimited Mockups at a time

Unlimited Design image at a time

4 Resizing Options

6 Alignment Options

3 Output Options (PSD, JPG, PNG)

Auto Output Folder By Template Name

Auto Output Folder By Save Option

 

 

bulkmockupsfiller . Com

 

 

Abdul karim mia
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