Skip to main content
Stephen Marsh
Community Expert
Community Expert
November 19, 2022
질문

Bridge Script to Add Missing Resolution Metadata to Exported JPEG Files

  • November 19, 2022
  • 0 답변들
  • 710 조회

This script will add 300ppi resolution metadata to selected JPEG files (JPG or JPEG extensions). This may be desired when making use of Photoshop's Export features which are designed to strip irrelevant metadata that is not required for web/device viewing. Some users still wish to have the resolution metadata included, but do not wish to use Save As/Save a Copy which includes all metadata.

 

This is a continuation of the topic in the Photoshop forum where I created a couple of similar scripts for Photoshop:

 

https://community.adobe.com/t5/photoshop-ecosystem-discussions/script-to-add-missing-resolution-metadata-to-exported-jpeg-files/td-p/13335061

 

/*
Set JPEG Resolution Metadata to 300ppi.jsx
v1.0, 19th November 2022, Stephen Marsh
Add the stripped resolution metadata back to exported JPEG files
https://community.adobe.com/t5/bridge-discussions/bridge-script-to-add-missing-resolution-metadata-to-exported-jpeg-files/td-p/13357144
*/

#target bridge

if (BridgeTalk.appName == "bridge") {
    addResMeta = new MenuElement("command", "Set JPEG Resolution Metadata to 300ppi", "at the end of Tools");
}

addResMeta.onSelect = function () {

    //var sels = app.document.selections;
    var sels = app.document.getSelection("jpg, jpeg");

    for (var i = 0; i < sels.length; i++) {
        var thumb = sels[i];
        var md = thumb.metadata;
        var res = 300;

        md.namespace = "http://ns.adobe.com/photoshop/1.0/";
        md.XResolution = res;
        md.namespace = "http://ns.adobe.com/photoshop/1.0/";
        md.DisplayedUnitsX = 'inches';
        md.namespace = "http://ns.adobe.com/photoshop/1.0/";
        md.YResolution = res;
        md.namespace = "http://ns.adobe.com/photoshop/1.0/";
        md.DisplayedUnitsY = 'inches';

        md.namespace = "http://ns.adobe.com/tiff/1.0/";
        md.XResolution = res;
        md.namespace = "http://ns.adobe.com/tiff/1.0/";
        md.YResolution = res;
        md.namespace = "http://ns.adobe.com/tiff/1.0/";
        md.ResolutionUnit = 2;

        // Appears to be a bug that this doesn't work as expected when called from a script
        //app.document.chooseMenuItem("PurgeCacheForSelected");
    }
    // Prompt user to purge cache for the folder (to force an update of the displayed metadata for all files)
    app.document.chooseMenuItem("PurgeCache");
}

 

 

https://prepression.blogspot.com/2017/11/downloading-and-installing-adobe-scripts.html

 

이 주제는 답변이 닫혔습니다.