Is there a quick way to get the pixel dimensions of a selected thumbnail?
I've attempted to use BitmapData but to no avail.
TIA
Getting Image Pixel Dimensions
Getting Image Pixel Dimensions
Here is a BridgeTalk message example for getting the data from Photoshop. You could adapt is to run in Bridge without BrideTalk.
Code: Select all// adapted from Paul Riggott
var fileName = '/c/cameron.psd';
var dimensions = undefined;
// Code for send message and handling response
// in the sending application (any message-enabled application)
var res = undefined;
var bt = new BridgeTalk;
bt.target = "bridge";
// the script passed to the target application
var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+fileName.toSource()+");");//define the work function and call it with arguments
bt.body = myScript;
bt.onResult = function( inBT ) {myReturnValue(inBT.body); }// call the result processing function
// send the message and wait up to 10 sec for responce
bt.send(10);
// function to process the return string
function myReturnValue(str){
//process the results. here just assign strings
res = str;
dimensions = str.split(',');
}
// wrap your script in a function
// this function is in whatever DOM the bridgeTalk target is. In this case Bridge
// don't have comments in the psRemote function
function psRemote(fileName){
var file = new File(fileName);
var tn= new Thumbnail(file);
var md = tn.synchronousMetadata;
var x = md.read('http://ns.adobe.com/exif/1.0/',"PixelXDimension");
var y = md.read('http://ns.adobe.com/exif/1.0/',"PixelYDimension");
return [x,y];
}
alert('Image is '+dimensions[0]+' px wide and '+dimensions[1]+' px heigh');
Code: Select all// adapted from Paul Riggott
var fileName = '/c/cameron.psd';
var dimensions = undefined;
// Code for send message and handling response
// in the sending application (any message-enabled application)
var res = undefined;
var bt = new BridgeTalk;
bt.target = "bridge";
// the script passed to the target application
var myScript = ("var ftn = " + psRemote.toSource() + "; ftn("+fileName.toSource()+");");//define the work function and call it with arguments
bt.body = myScript;
bt.onResult = function( inBT ) {myReturnValue(inBT.body); }// call the result processing function
// send the message and wait up to 10 sec for responce
bt.send(10);
// function to process the return string
function myReturnValue(str){
//process the results. here just assign strings
res = str;
dimensions = str.split(',');
}
// wrap your script in a function
// this function is in whatever DOM the bridgeTalk target is. In this case Bridge
// don't have comments in the psRemote function
function psRemote(fileName){
var file = new File(fileName);
var tn= new Thumbnail(file);
var md = tn.synchronousMetadata;
var x = md.read('http://ns.adobe.com/exif/1.0/',"PixelXDimension");
var y = md.read('http://ns.adobe.com/exif/1.0/',"PixelYDimension");
return [x,y];
}
alert('Image is '+dimensions[0]+' px wide and '+dimensions[1]+' px heigh');
Getting Image Pixel Dimensions
You could just switch this on in the app preferences couldn't you? It would show for all thumbnails in every window thou.
Preferences/General/Additional Lines of Thumbnail Metadata/ allows 3 'show' options set 1 of these to 'dimensions'
it also includes @ whatever DPI if raster data… You can also turn on/off these options via script…
Code: Select all#target bridge
app.bringToFront();
app.preferences.showName = false;
app.document.showThumbnailName = true;
// Max 3 item Array
app.preferences.extraMetadata = [4,11,12];
/*
Corrected key number mapping!!! as GUI
0: Sets non showing
1: Date Created
2: Date Modified
3: File Size
4: Dimensions
5: Label
6: Author
7: Keywords
8: Description
9: Copyright
10: Color Profile
11: Color Mode
12: Bit Depth
13: Document Kind
14: Document Creator
15: Opening Application
16: Exposure
17: Focal Length
Adobe's key number mapping as CS2 Guide???
1: DateCreated
2: DateModified
3: Dimensions
4: Label
5: Author
6: Keywords
7: Copyright
8: ColorMode
9: BitDepth
10: DocumentCreator
11: OpeningApplication
12: Exposure
*/
Preferences/General/Additional Lines of Thumbnail Metadata/ allows 3 'show' options set 1 of these to 'dimensions'
it also includes @ whatever DPI if raster data… You can also turn on/off these options via script…
Code: Select all#target bridge
app.bringToFront();
app.preferences.showName = false;
app.document.showThumbnailName = true;
// Max 3 item Array
app.preferences.extraMetadata = [4,11,12];
/*
Corrected key number mapping!!! as GUI
0: Sets non showing
1: Date Created
2: Date Modified
3: File Size
4: Dimensions
5: Label
6: Author
7: Keywords
8: Description
9: Copyright
10: Color Profile
11: Color Mode
12: Bit Depth
13: Document Kind
14: Document Creator
15: Opening Application
16: Exposure
17: Focal Length
Adobe's key number mapping as CS2 Guide???
1: DateCreated
2: DateModified
3: Dimensions
4: Label
5: Author
6: Keywords
7: Copyright
8: ColorMode
9: BitDepth
10: DocumentCreator
11: OpeningApplication
12: Exposure
*/
Getting Image Pixel Dimensions
Thanks Mike and larsen67 for responding to my query.
In an attempt to keep my question concise, I didn't explain myself completely. I'm intending to use the pixel dimensions for further processing within another script.
In my preferences I do have Dimensions enabled and they are visible in the Metadata tab.
From the code Mike provided, I came up with the snippet below but the alert is giving me the following (single thumbnail selected).
Metadata is [object Metadata]
By changing the alert to alert(thumb.name);. I can get the name of the of a selected thumbnail so I assume I need to convert the metadata to a string or parse the information in some way.
Code: Select all#target bridge
var selectedThumbnails = app.document.getSelection();
var thumb = selectedThumbnails[0];
var md = thumb.synchronousMetadata;
alert("Metadata is " + md);
In an attempt to keep my question concise, I didn't explain myself completely. I'm intending to use the pixel dimensions for further processing within another script.
In my preferences I do have Dimensions enabled and they are visible in the Metadata tab.
From the code Mike provided, I came up with the snippet below but the alert is giving me the following (single thumbnail selected).
Metadata is [object Metadata]
By changing the alert to alert(thumb.name);. I can get the name of the of a selected thumbnail so I assume I need to convert the metadata to a string or parse the information in some way.
Code: Select all#target bridge
var selectedThumbnails = app.document.getSelection();
var thumb = selectedThumbnails[0];
var md = thumb.synchronousMetadata;
alert("Metadata is " + md);
Getting Image Pixel Dimensions
Code: Select all#target bridge
// Returns Array
var selectedThumbnails = app.document.selections;
// Test with first item of Array
var thumb = selectedThumbnails[0];
// Get metadata from thumbnail
var md = thumb.synchronousMetadata;
// Read from namespace
var x = md.read('http://ns.adobe.com/exif/1.0/',"PixelXDimension");
var y = md.read('http://ns.adobe.com/exif/1.0/',"PixelYDimension");
alert('Image is ' + x + ' px wide and ' + y + ' px heigh');
// Returns Array
var selectedThumbnails = app.document.selections;
// Test with first item of Array
var thumb = selectedThumbnails[0];
// Get metadata from thumbnail
var md = thumb.synchronousMetadata;
// Read from namespace
var x = md.read('http://ns.adobe.com/exif/1.0/',"PixelXDimension");
var y = md.read('http://ns.adobe.com/exif/1.0/',"PixelYDimension");
alert('Image is ' + x + ' px wide and ' + y + ' px heigh');
Getting Image Pixel Dimensions
larsen67 & Mike Hale:
Thank you both for hanging in there with me, what you provided is exactly what I needed.
For the sake of me learning something from this, could you enlighten me or provide me some reference as to the use of Hypertext Transfer Protocol for application scripting.
Admittedly, I'm new to scripting Bridge and I have limited experience scripting Photoshop & After Effects so maybe it's more prevalent than I realize but I'm having difficulty understanding how to employ it.
Once again, thanks again guys; you made my day...
Thank you both for hanging in there with me, what you provided is exactly what I needed.
For the sake of me learning something from this, could you enlighten me or provide me some reference as to the use of Hypertext Transfer Protocol for application scripting.
Admittedly, I'm new to scripting Bridge and I have limited experience scripting Photoshop & After Effects so maybe it's more prevalent than I realize but I'm having difficulty understanding how to employ it.
Once again, thanks again guys; you made my day...
Getting Image Pixel Dimensions
I think I found the information I was looking for.
http://www.adobe.com/products/xmp/
Thanks again guys...
http://www.adobe.com/products/xmp/
Thanks again guys...