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

Issues with varying DPI and replacing Smart Object

Community Beginner ,
Feb 14, 2018 Feb 14, 2018

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.

TOPICS
Actions and scripting

Views

514

Translate

Translate

Report

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
Adobe
Community Beginner ,
Feb 15, 2018 Feb 15, 2018

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]

Votes

Translate

Translate

Report

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
Valorous Hero ,
Feb 15, 2018 Feb 15, 2018

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

Votes

Translate

Translate

Report

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 Beginner ,
Feb 15, 2018 Feb 15, 2018

Copy link to clipboard

Copied

PNG and JPEGS

Votes

Translate

Translate

Report

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
Valorous Hero ,
Feb 15, 2018 Feb 15, 2018

Copy link to clipboard

Copied

You yourself can not write a script by the algorithm, what did I say?

Votes

Translate

Translate

Report

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 ,
Feb 15, 2018 Feb 15, 2018

Copy link to clipboard

Copied

LATEST

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.

JJMack

Votes

Translate

Translate

Report

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