Copy link to clipboard
Copied
I am trying to batch process mockup images.
I made a set of actions:
Open
Edit Contents
Place
Flatten Image
Save
Update Smart Object
Close
But I am getting an error stating "edit objects not available" and if trying another way then "x object not available"
I have attached images for reference please help me. I am badly stuck. !
Copy link to clipboard
Copied
Actions are not scripts they are step step step. When played and fail ina step loot at the action pallets step and the state of the current document to see what went wrong. Posting your action would help
Copy link to clipboard
Copied
Hi!
I have attached a image of the actions I have created. In the actions the main issue is the place file is not replacing with the other images. It is only picking up the same image and making all the mockups with the same 1st image. !
Copy link to clipboard
Copied
Place, does not replace it places in a new smart object layer. And that place step will always place in the file recorded in the step 2.jpg.
Copy link to clipboard
Copied
Hello! Ok got it so how can this be solved? What should be used instead of place?
Copy link to clipboard
Copied
Hi Rohit,
Try this code...
#target photoshop
if (app.documents.length > 0) {
var docRef = app.activeDocument;
var theName = docRef.name.match(/(.*)\.[^\.]+$/)[1];
var docPath = docRef.path;
var theLayer = docRef.layers.getByName('YOUR CASE'); ;
// check if layer is smart object;
if (theLayer.kind != "LayerKind.SMARTOBJECT") {
alert("selected layer is not a smart object")
} else {
// select files;
var theFolder = Folder.selectDialog("select folder");
if (theFolder) {
var theFiles = theFolder.getFiles(/\.(jpg|tif|eps|psd|png)$/i);
// work through the array;
for (var m = 0; m < theFiles.length; m++) {
// replace smart object;
theLayer = replaceContents(theFiles
, theLayer); var theNewName = theFiles
.name.match(/(.*)\.[^\.]+$/)[1]; //save jpg;
OutFoldJPG(docPath,theNewName+".jpg",true,12,FormatOptions.STANDARDBASELINE,Extension.LOWERCASE,"JPG");
}
};
}
};
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
};
function OutFoldJPG(docPath,dnme,cProfile,jpegQuality,MType,fCase,flagFormat){ //OutFoldTIFF(filePath,fileName,true,TIFFEncoding.TIFFLZW,Extension.LOWERCASE)
var outfolder = new Folder(docPath+"/"+flagFormat);
if (outfolder.exists == false){
outfolder.create();
var saveFile = new File(outfolder + "/" + dnme);
SaveJPG(saveFile,cProfile,jpegQuality,MType,fCase);}
else{
var saveFile = new File(outfolder + "/" + dnme);
SaveJPG(saveFile,cProfile,jpegQuality,MType,fCase);}
}
function SaveJPG(saveFile, jpegQuality,cProfile,formaType,fCase){//12,true,MatteType.NONE
//alert(saveFile+"\n"+cProfile+"\n"+jpegQuality+"\n"+fCase+"\n"+formaType);
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile=cProfile;
jpgSaveOptions.formatOptions = formaType//FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE
jpgSaveOptions.quality = jpegQuality; //1-12
activeDocument.saveAs(saveFile, jpgSaveOptions, true,fCase);
}
- yajiv
Copy link to clipboard
Copied
Hi
Thanks for script!
The script is working but only a part of the image is being fitted in the mockup after zooming. The image sizes are 960 px x 1896 px. Only a part of the image is being showed on the mockup. When replacing it is not picking up the original size of the jpg which is 960 px x 1896 px. It is making the image very big which is 4635px X 7975px.
How can we solve this?
Copy link to clipboard
Copied
Smart object layers have an associated transform, All replacements must be the same size and resolution as the original object in the mock. They will all be transformed like the mockup object. The smart object associated transform is not replaced or altered when you replace smart object layers content. All replacement images need to be preprocesses to have the same aspect ratio and number of pixels as the original object. That is why I do not use replace contents populating mockup. I place in smart object layers set their transform to resize and position the images then mask it to shape.
Copy link to clipboard
Copied
Hi
The script is working! But the quality output is not good. The file size is 103 Kb but while doing one manually the file size is 950 Kb. The size is being reduced. The size is being reduced of the jpg while saving. Please help out with this.
Thanks in advance!
Copy link to clipboard
Copied
If you want to use replace content of a smart object layer. All replacement object must be exactly the same size and resolution as the object in the template mockup file. A script would be needed to automate that process. I like to be able to handle any size image. So my templates only map the size location and shape of image using alpha channels Your images will be placed in by my scripts as smart object layers then the scripts will resize the placed in images position them and mask them to shape..
Copy link to clipboard
Copied
Hi
Can you provide me a script for this?
Thanks.
Copy link to clipboard
Copied
Photo Collage Toolkit
Photoshop scripting is powerful and I believe this package demonstrates this. A video showing a 5 image collage PSD template being populated with images:
The package includes four simple rules to follow when making Photo Collage Template PSD files so they will be compatible with my Photoshop scripts.
There are fifteen scripts in this package they provide the following functions:
Copy link to clipboard
Copied
Scripts are Automated Photoshop processes that are added to Photoshop like Actions and Plug-in like Fitters like ACR and other add-ons. Photoshop ships with some scripts you may have used. Like Photomerge, Lens correction, .Fit Image, Merge to HDR Pro, Image Processor, Load Files into a stack., etc They are Photoshop tools and like other tools may have dependencies. Like to use My scripts on you need create templates and use templates that follow my design rules or you need to download templates the do..
Copy link to clipboard
Copied
It will fail as you have a "Flatten Image" doing this you will no longer have a smart object.