Copy link to clipboard
Copied
Use the ps script to get the exif of the image without opening it in photoshop?

Copy link to clipboard
Copied
You might have a good look at Exiftool, which can read out pretty much any metadata of your document.
Hope this can help.
Copy link to clipboard
Copied
Thank you,i know the software ,but i just went to use PS JavaScript 。。。。
Copy link to clipboard
Copied
#target photoshop;
ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
var s = File.openDialog("Please select JPG file.","JPG File:*.jpg");
var file = new XMPFile(File(s).fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_READ);
var xmp = file.getXMP();
if( xmp.doesPropertyExist(XMPConst.NS_EXIF, "PixelXDimension" ) ) {
var x= xmp.getProperty(XMPConst.NS_EXIF, "PixelXDimension" );
var y= xmp.getProperty(XMPConst.NS_EXIF, "PixelYDimension" );
alert("X = " + x + " Y = " + y );
}else{
alert("This files does not have EXIF dimensions");
}
Copy link to clipboard
Copied
I used the same method but later I found it doesn't take into consideration if file was rotated in system (Windows / OS).
So later I created own method where I read binaries, while now I use even something simpler for all formats and rotations.
Copy link to clipboard
Copied

this is ok!!!
but , Only for raw files? Why so many images unable to read size information?
Copy link to clipboard
Copied
Only for raw files? Why so many images unable to read size information?
su仙人 – the script provided by SuperMerlin is looking specifically for EXIF resolution metadata.
If the file does not contain this metadata, then the size can’t be reported. This was the case for my Canon CR2 files. This was also the case for JPEG files where the metadata had been stripped out.
If a common resolution source could not be found for all file formats, then more complex script would be needed to look for different known metadata in different image file formats.
Copy link to clipboard
Copied
Thanks so much for response
Copy link to clipboard
Copied
Yes @Stephen_A_Marsh is correct if there is no EXIF if would not get the X/Y
This script should, but only for JPGs
#target photoshop;
String.prototype.WidthHeight = function(pos){
var wh = new Array();
var hi = this.charCodeAt(pos);
var lo = this.charCodeAt(pos+1);
wh.push( (hi << 8) + lo);
hi = this.charCodeAt(pos+2);
lo = this.charCodeAt(pos+3);
wh.push( (hi << 8) + lo);
return wh;
}
function main(){
var file = File.openDialog("Please select JPG file.","JPG File:*.jpg");
file.open('r');
file.encoding='BINARY';
var filedata = file.read();
file.close();
var pos = new Array();
var RE = /\xFF\xC0/g;
while(match = RE.exec(filedata)){pos.push(match.index);}
var position = (pos[Number(pos.length-1)]);
var HeightWidth = filedata.WidthHeight(position+5);
var ratio = HeightWidth[1]/HeightWidth[0];
alert("X = " + HeightWidth[1] + " Y = " + HeightWidth[0]);
}
main();
Copy link to clipboard
Copied
Thanks for your reply
Copy link to clipboard
Copied
Hi @SuperMerlin. Part of your code is showing emojis for some reason... Can you clarify the string of characters needed to replace these?
Copy link to clipboard
Copied
Just found the answer to my own question after trying a few strings... The emoji is being substituted for the sequential string of characters "8" and ")" when written on this forum...
Great script!
Copy link to clipboard
Copied
Is there also a way to capture the X and Y resolution metadata from PNG files without opening directly?
Copy link to clipboard
Copied
“You might have a good look at Exiftool, which can read out pretty much any metadata of your document.”
Although su仙人 requires Photoshop JavaScript code… Just in case anybody would like to explore the ExifTool suggestion, the command line code on a Mac OS would be:
exiftool -composite:imagesize 'path to file or folder'
or the shorthand form:
exiftool -imagesize 'path to file or folder'
or
exiftool -file:imagewidth -file:imageheight 'path to file or folder'
or the shorthand form:
exiftool -imagewidth -imageheight 'path to file or folder'
P.S. There are also EXIF tags that report dimensions (-ExifIFD:ExifImageWidth / -ExifIFD:ExifImageHeight or -ExifImageWidth / -ExifImageHeight), however they may not always exist if metadata has been removed, so the previous noted tags are safer to use.
NOTE: Simply swap the straight single quote marks for straight double quote marks on Windows OS.
Copy link to clipboard
Copied
What file format - .jpg, .psd, other? What language do you use in your Photoshop - English, Japanese, other?
Copy link to clipboard
Copied
is jpg , I use Chinese in my Photoshop
Copy link to clipboard
Copied
This scripts works for all kind of file formats also takes into consideration if the file was rotated in system:
(function(v){
function sTT(v) {return stringIDToTypeID(v)}; function f(v1, v2) {
if (arguments.length < 2) return r.getInteger(sTT(v1), 'px')
return executeAction(sTT(v1 + 'ViewlessDocument'), v2)
}
(dsc1 = new ActionDescriptor()).putBoolean(sTT('preferXMPFromACR'), true)
dsc1.putPath(sTT('file'), v), (r = f('open', dsc1)).getData(d = sTT('document'));
(dsc2 = new ActionDescriptor()).putData(d, r.getData(d)), f('close', dsc2)
return [f('width'), f('height')]
})(File('~/desktop/someFile.jpg'))
Copy link to clipboard
Copied
You are still opening the document even though it can't be seen, the OP asked that it was not opened.
Copy link to clipboard
Copied
Your method is good and as I said it's something I used too till I found I never can be sure was a file rotaed before I'd like later to open it in Ps. If I used it still then I could not immediately play some script on just opened image in Ps without checking its orientation and if wrong then doing necessary rotation.
Your method is the fastest though, but I don't think OP was clear enough what he wants. That script I wrote doesn't open a file that we can see it, so after all maybe for su仙人 that was what she wanted - no blinking effect.
And however it opens a file it works much faster than regular opening & closing a file, so when you remarkably see it.
Yours takes 1 mm, mine 33 mm, and normal one 150 mm for just small file. So 'viewless' one is 5 times faster than normal.
Copy link to clipboard
Copied
Yes you can process files with VB,C# etc without them showing and it does speed up the process and you have more control than usining viewless.
Copy link to clipboard
Copied
As to C# I believe we can do much more than with Javascript, but for now I don't have power to learn another language. Regarding VB that's possible one day I will do that what I do now with ActionManager. I don't use VB language too until Javascript fails, so that's good notice.
To su仙人: if you want to be alerted in Photoshop of result, change:
return [f('width'), f('height')]
to:
return alert(return [f('width'), f('height')])
Copy link to clipboard
Copied
@Kukurykus:
dsc1.putPath(sTT('file'), v) always gives a PS error message. What's wrong with it? I am using PS CC 2018.
Copy link to clipboard
Copied
Did you use your own path, or remained '~/desktop/someFile.jpg' ? If you did not use any other then you should save on desktop a file named someFile.jpg. If you did use other path, copy it here, maybe there's some mistake / it works in CC2018
Copy link to clipboard
Copied
If you want to get the EXIF info and not open the file, how about scripting it through Bridge? Or is that slower, as you can't use AM code?
Copy link to clipboard
Copied
They may not have Bridge installed? but for non raw files using xmpFile works just the same for Photoshop or Bridge.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now