Copy link to clipboard
Copied
Can anyone direct me where to build a script for Bridge.
I would like to build a script to convert the Dimensions (in inches) metadata to the dimensions if the the size was reduced to 3" on the largest side and put it in the description metadate line.
This should work. Save as PLAIN TEXT with .jsx extension and copy into the Bridge Startup Scripts folder. Restart Bridge, select your files, right-click "Ratio to Description".
/*
Utility Pack Scripts created by David M. Converse ©2018-23
This script writes dims to description
Last modified 3/9/2023
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.
...
Copy link to clipboard
Copied
This can certainly be done, but be aware that images are measured in pixels and inches are a derived property. If PPI data is changed or deleted, the derived inch measurement will also change.
Copy link to clipboard
Copied
Thank you for the heads up. Would it be possible to have the script over write itself up request?
Copy link to clipboard
Copied
I'm not sure what you are asking, sorry.
Copy link to clipboard
Copied
Oh, its likely due to my lack of knowledge on the subject. I don't even know how to explain it properly. I was simply confirming that, I could potentially be able to run the script again and replace the description again with the updated size as it would be based off the pixel data.
More so, is there somewhere where to start for the novice such as myself?
Copy link to clipboard
Copied
Yes you can change metadata at any time.
I already have a script that writes to the description, I'll post it here when I get time. Shouldn't be hard to modify.
Copy link to clipboard
Copied
I would greatly appreciate that. Thank you,
Copy link to clipboard
Copied
This should work. Save as PLAIN TEXT with .jsx extension and copy into the Bridge Startup Scripts folder. Restart Bridge, select your files, right-click "Ratio to Description".
/*
Utility Pack Scripts created by David M. Converse ©2018-23
This script writes dims to description
Last modified 3/9/2023
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#target bridge
if(BridgeTalk.appName == 'bridge'){
var ratioCmd = MenuElement.create('command', 'Ratio to Description', 'after Thumbnail/Open', this.menuID); //add to Contextual menu
}
ratioCmd.onSelect = function(){
ratioMain();
}
ratioMain = function(){
var descThumbs = app.document.selections; //get selected thumbnails
var dims = '';
var h = 0;
var w = 0;
if(ExternalObject.AdobeXMPScript == undefined) ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
if(!descThumbs.length) return; //nothing selected
for(var a in descThumbs){ //loop through thumbs
if(!descThumbs[a].container){
try{
var descMeta = descThumbs[a].synchronousMetadata;
var descXMP = new XMPMeta(descMeta.serialize());
descXMP.deleteProperty(XMPConst.NS_DC, 'description');
h = descThumbs[a].core.quickMetadata.height;
w = descThumbs[a].core.quickMetadata.width;
if(h > w){
dims = '3\"H x ' + (w/h*3).toString() + '\"W';
}
else{
dims = (h/w*3).toString() +'\"H x ' + '3\"W';
}
descXMP.setLocalizedText(XMPConst.NS_DC, 'description', null, 'x-default', dims);
var descUpdatedPacket = descXMP.serialize(XMPConst.SERIALIZE_OMIT_PACKET_WRAPPER | XMPConst.SERIALIZE_USE_COMPACT_FORMAT);
descThumbs[a].metadata = new Metadata(descUpdatedPacket); //write to file
}
catch(e){
alert(e + e.line);
}
}
}
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
ReferenceError: XMPMeta does not have a constructor37
Copy link to clipboard
Copied
Ah yeah there is a library that has to be loaded, I updated the script above.
Copy link to clipboard
Copied
Thank you, it works perfectly.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now