Copy link to clipboard
Copied
So we are using this script
// Replace SmartObject Contents
function replaceContents(newFile, theSO) {
try {
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);
} catch (e) {
writeLog("ERROR 1 - " + e.message);
return false;
}
return app.activeDocument.activeLayer;
};
If we have a 2000x200 300 DPI file this works fine. But if the DPI is different, BUT the same total pixels then the mockup does not look right. We cannot control what our customers upload into our system and we'd rather not normalize the DPI before we send to Photoshop.
Since I'm not super skilled in this area, I'm hoping someone can tell me what I'm doing wrong. So we can pass through any DPI to the Smart Object and get the proper mockup output.
Copy link to clipboard
Copied
I am missing to pay for some help on this.
Please email me at [Personal info removed - please do not post personal info on this public forum]
Copy link to clipboard
Copied
What type of files are you trying to place?
You can open the file before place, change its resolution, save it to a temporary folder, and then execute placedLayerReplaceContentsto with this temporary file.
All through a script...
Copy link to clipboard
Copied
PNG and JPEGS
Copy link to clipboard
Copied
You yourself can not write a script by the algorithm, what did I say?
Copy link to clipboard
Copied
If you have images that have differences in sizes and aspect ratio that you want to place into mockup templates that can be done but not by replacing the contends of a smart object layer image layer that is in the template PSD. ( Layer>Smart Objects>Replace Content... ) Because all smart object layer have an transform associated the layer's object which is not replaced or changed when the object contents is replaced. If the replacement object is not the same size as the object in the template the associated transform will not work correctly.
If all images have the same aspect ratio you can open the smart object layer's object if it is an Photoshop object. Not a placed RAW file or placed Illustrator file. So when you create your template do not place in RAW file or illustrator fill you intend to replace. When Photoshop open the work document for the object you can update the document with the new replacement image top layer sized to the work document canvas for it has the same aspect ratio, other layers will be covered.close and commit the change. Photoshop will update the smart object layer's object with the updated content. The associated transform will work correctly, sizing, positioning, warping, rotation all will work.
If images do not have the same aspect ratio you have problems. If you size it to fill the canvas some image content will be outside the canvas and the document canvas will clip the image to a virtual center crop to the right aspect ratio you loose content if you use content aware resize you have distortion.