Copy link to clipboard
Copied
I want to make 3-4 mock-up/show cases images for each art photos, now I am process manually and very time consuming, any script can make these processing automatically
Like this sample effect (manually made, how to auto ?)
Copy link to clipboard
Copied
There have been several of threads on this issue.
Please do a Forum search (»template replace script« for example) and if you have further questions provide the files or at the very least post meaningful screenshots that illustrate the template file’s Layer structure – did you set up the placed image as a Smart Object?
Copy link to clipboard
Copied
My mock up file is like this
1. I open this file
2. The middle layer is linked to another PSD file, double click will open this file
3. Place the art image on this file and adjust size to fit (I did not set up the image as smart object)
4. Save and close and back to the mock up file
5. Save as jpeg
I need open 3-4 mock up files to repeat step 2-5, then I have 3-4 mock up images
Am I doing in stupid way ?
Any script can do it in batch?
Or any tutorial I can make my own script ?
Thanks
Copy link to clipboard
Copied
Am I doing in stupid way ?
Do all the replacement files have the same dimensions as the originally placed image?
Copy link to clipboard
Copied
That is my most headache problem, for example : I have 5 files, there dimention are :
2419*4730, 1112*867, 735*914, 2767*2012, 3901*3037 (Pixels)
Then I need put these 5 images into my mock-up set (4 mock-up files), finally, I got total 20 mocked-up files in jpeg format.
So, each time I place image into the middle layer, I need to adjust size, some time need to crop the image.
Such complicated processing, any script can do it ?
Thank you
Copy link to clipboard
Copied
That is my most headache problem, for example : I have 5 files, there dimention are :
2419*4730, 1112*867, 735*914, 2767*2012, 3901*3037 (Pixels)
Then I need put these 5 images into my mock-up set (4 mock-up files), finally, I got total 20 mocked-up files in jpeg format.
So, each time I place image into the middle layer, I need to adjust size, some time need to crop the image.
That seems like bad planning.
But a Smart-Object-in-Smart-Object-approach should be more or less able to handle the situation.
And »some time need to crop« seems like a pointless statement when is comes to Scripting.
At what time exactly do you need to crop? Which exact parameters determine if, when and what has to be cropped?
Do the current Smart Objects in all 4 mock-ups have the exact same dimensions at least?
Please provide one of the template files and the set of replacement images (feel free to blacken out any sensitive elements).
Copy link to clipboard
Copied
Thank you very much, I uplaoded 3 set (image+mockup+finished image), you can see what the problem is :
1. My images are not same aspect ratio
2. The BatchMockupTemplates.jsx by JJMack limted the smart object layer need to be 1st layer
See if you can give me some advises
Copy link to clipboard
Copied
I found a similiar, but I don't know how it can handle differnt aspect ratio, take a look and appreciated for any advises
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I downloaded, but NO MOCK-UP template file in zip file, so I can not test
If you have a mock-up file work for this script (BatchMockupTemplates.jsx), please upload and let me test, thank you very much
Copy link to clipboard
Copied
There are links to very specific simple instructions that the script requires for use.
Copy link to clipboard
Copied
I tried my template files, you can see the script do not know how to resize replace file (art image), here is the result
Copy link to clipboard
Copied
Copy link to clipboard
Copied
There are many mock-up smart object replacement scripts on the forum if you search. It is hard for them to be generic or general purpose as they are usually created for a specific project.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
The Script from that thread could be modified – either to offer an additional file-selection dialog to select the templates or by hard-coding the templates’ paths into the Script.
Copy link to clipboard
Copied
Thank you very much, it works like a charm, I just need to group the jpg in same aspect ratio, then will auto done for me.
Copy link to clipboard
Copied
Actually that Script should fit the images into the Smart Object anyway.
Or did you want to clip them so they fill the SO but lose the parts on the side (or top/bottom)?
Copy link to clipboard
Copied
I will find different aspect ratio mock-up files and group them, then 3:2 images will use 3:2 mock-up PSD, 5:7 will use 5:7 mock-up........
Appreciated if you can modify a bit make it like JJMack's BatchMockupTemplates.jsx point to 2 folder - images folder and mock-up folder, then finish 3-4 set mockup images automatically that will be a great help.
Sorry for too greedy to ask this, thank you.
Copy link to clipboard
Copied
// select template files, select images to be placed;
// place selected images in active smart object and save jpgs;
// 2023, use it at your own risk;
// Select Files;
if ($.os.search(/windows/i) != -1) {
var theTemplates = File.openDialog("please select template files", "*.psd;*.tif;*.jpg", true)
} else {
var theTemplates = File.openDialog("please select template files", getFiles, true)
};
if (theTemplates) {
if ($.os.search(/windows/i) != -1) {
var theFiles = File.openDialog("please select image files", "*.psd;*.tif;*.jpg", true)
} else {
var theFiles = File.openDialog("please select image files", getFiles, true)
};
if (theFiles) {
for (var x = 0; x < theTemplates.length; x++) {
var myDocument = app.open(File(theTemplates[x]));
var theName = myDocument.name.match(/(.*)\.[^\.]+$/)[1];
var thePath = myDocument.path;
var theLayer = myDocument.activeLayer;
// JPG Options;
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 11;
// Check if layer is SmartObject;
if (theLayer.kind != "LayerKind.SMARTOBJECT") {
alert("selected layer is not a smart object")
} else {
// Select Files;
if (theFiles) {
for (var m = 0; m < theFiles.length; m++) {
var theState = myDocument.activeHistoryState;
var theSO = openSmartObject ();
placeScaleRotateFile (theFiles[m], 0, 0, 100, 100, 0);
scaleToCanvasSize ();
theSO.close(SaveOptions.SAVECHANGES);
var theNewName = theFiles[m].name.match(/(.*)\.[^\.]+$/)[1];
// Save JPG
myDocument.saveAs((new File(thePath + "/" + theName + "_" + theNewName + ".jpg")), jpgSaveOptions, true,Extension.LOWERCASE);
myDocument.activeHistoryState = theState;
}
}
}
}
}
};
// Get PSDs, TIFs and JPGs from files
function getFiles(theFile) {
if (theFile.name.match(/\.(psd|tif|jpg)$/i) != null || theFile.constructor.name == "Folder") {
return true
};
};
// Replace SmartObject 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
};
////// open smart object //////
function openSmartObject () {
var desc2 = new ActionDescriptor();
executeAction( stringIDToTypeID( "placedLayerEditContents" ), desc2, DialogModes.NO );
return activeDocument;
};
////// place //////
function placeScaleRotateFile (file, xOffset, yOffset, theXScale, theYScale, theAngle) {
// =======================================================
var desc5 = new ActionDescriptor();
desc5.putPath( charIDToTypeID( "null" ), new File( file ) );
desc5.putEnumerated( charIDToTypeID( "FTcs" ), idQCSt = charIDToTypeID( "QCSt" ), charIDToTypeID( "Qcsa" ) );
var idOfst = charIDToTypeID( "Ofst" );
var desc6 = new ActionDescriptor();
var idPxl = charIDToTypeID( "#Pxl" );
desc6.putUnitDouble( charIDToTypeID( "Hrzn" ), idPxl, xOffset );
desc6.putUnitDouble( charIDToTypeID( "Vrtc" ), idPxl, yOffset );
var idOfst = charIDToTypeID( "Ofst" );
desc5.putObject( idOfst, idOfst, desc6 );
var idPrc = charIDToTypeID( "#Prc" );
desc5.putUnitDouble( charIDToTypeID( "Wdth" ), idPrc, theYScale );
desc5.putUnitDouble( charIDToTypeID( "Hght" ), idPrc, theXScale );
desc5.putUnitDouble( charIDToTypeID( "Angl" ), charIDToTypeID( "#Ang" ),theAngle );
desc5.putBoolean( charIDToTypeID( "Lnkd" ), false );
executeAction( charIDToTypeID( "Plc " ), desc5, DialogModes.NO );
return app.activeDocument.activeLayer;
};
////// scale active layer to canvas dimensions //////
function scaleToCanvasSize () {
// scale smart object:
var originalRulerUnits = app.preferences.rulerUnits;
app.preferences.rulerUnits = Units.PIXELS;
var ref = new ActionReference();
ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") );
var layerDesc = executeActionGet(ref);
var theBounds = layerDesc.getObjectValue(stringIDToTypeID('bounds'));
var theX = theBounds.getInteger(stringIDToTypeID('left'));
var theY = theBounds.getInteger(stringIDToTypeID('top'));
var theX2 = theBounds.getInteger(stringIDToTypeID('right'));
var theY2 = theBounds.getInteger(stringIDToTypeID('bottom'));
// determine the scale;
var theSOProp = activeDocument.width/activeDocument.height;
var theNewProp = (theX2 - theX)/(theY2 - theY);
if (theNewProp >= theSOProp) {var theScale = activeDocument.width / (theX2 - theX) * 100}
else {var theScale = activeDocument.height / (theY2 - theY) * 100};
// transform;
var desc23 = new ActionDescriptor();
var ref2 = new ActionReference();
ref2.putEnumerated( charIDToTypeID( "Lyr " ), charIDToTypeID( "Ordn" ), charIDToTypeID( "Trgt" ) );
desc23.putReference( charIDToTypeID( "null" ), ref2 );
var idOfst = charIDToTypeID( "Ofst" );
var desc24 = new ActionDescriptor();
var idPxl = charIDToTypeID( "#Pxl" );
desc24.putUnitDouble( charIDToTypeID( "Hrzn" ), idPxl, activeDocument.width/2 - (theX+(theX2-theX)/2) );
desc24.putUnitDouble( charIDToTypeID( "Vrtc" ), idPxl, activeDocument.height/2 - (theY+(theY2-theY)/2) );
desc23.putObject( idOfst, idOfst, desc24 );
var idPrc = charIDToTypeID( "#Prc" );
desc23.putUnitDouble( charIDToTypeID( "Wdth" ), idPrc, theScale );
desc23.putUnitDouble( charIDToTypeID( "Hght" ), idPrc, theScale );
desc23.putEnumerated( charIDToTypeID( "Intr" ), charIDToTypeID( "Intp" ), stringIDToTypeID( "bicubicAutomatic" ) );
desc23.putEnumerated( stringIDToTypeID( "freeTransformCenterState" ), stringIDToTypeID( "quadCenterState" ), stringIDToTypeID( "QCSAverage" ) );
// desc23.putBoolean( charIDToTypeID( "Cpy " ), true );
executeAction( charIDToTypeID( "Trnf" ), desc23, DialogModes.NO );
app.preferences.rulerUnits = originalRulerUnits;
};
Copy link to clipboard
Copied
Thank you very much; it works like a charm. I don’t know how to express my thanks; you help me a lot; you are a kind expert.