I can’t find anything touching this in the last few years, so…
I want to be able to read File Properties metadata, and read and write IPTC Core metadata in Adobe Photoshop files with AppleScript or JavaScript (using do script), but without opening the image in Photoshop or Bridge and without relying on add-ons being installed with the end user (unless I can bundle them in the FaceSpan app somehow).
I scoured the web and found this…
tell application "Image Events"
set theImage to open alias "/Users/kquosig/Desktop/Sample Rights Managed/TEST/23728502_JPT_CMP_BlueBathtub.psd"
set {nameList, valueList} to {name, value} of metadata tags of theImage
end tell
…but for some reason it doesn’t read all the IPTC Core metadata, and of course doesn’t read the ones I need. And gives no clue for modifying field data.
At minimum I need access to the Instructions, Provider, Source, and Copyright metadata.
Seems just insane that Adobe would have “hidden” this information so thoroughly, but it certainly does seem that way.
Kevin, I’ve only just taken up trying to learn JavaScript in the last couple of weeks (heavy going and more guides than I could shake a stick at!!!).
You would do well though to ask both your resent questions here too: http://www.ps-scripts.com/
I have a sample JavaScript by Paul Riggott that reads the encoding and quality type may be this could be adapted to suit your needs. These people are experts when it comes to JS with either Bridge or Photoshop. I did get a little luck with IPTC using Graphic Converter (does not open the file you just need to set the creator type back to Photoshop after. It did not like .eps format though)
This was the sample (if it posts OK)
var file = File.openDialog("Please select JPG file.","JPG File:*.jpg");
main(file);
function main(file){
file.open("r");
file.encoding = 'BINARY';
filestring = file.read();
file.close();
var count = filestring.search(/\xFF\xEC/);
if(count > 200) count = -1;
if(count != -1){//Yes it is Save ForWeb
count += 16;
var Quality = filestring[count].charCodeAt (0);
alert(decodeURI(file.name)+ " Save For Web, Quality " + Quality);
return;
}
count = filestring.search(/\xFF\xE1/);
if(count != -1){
filestring = filestring.substring(count+10);
count = filestring.search(/\xFF\xE1/);
}
if(count == -1) {//This file has not been edited with Photoshop!
alert(decodeURI(file.name)+" has not been edited/saved with Photoshop!");
return;
}
count -= 8;
var Result = 0;
var FormatType = 0;
if(filestring[count] == 0) {
}else{
Result = filestring[count].charCodeAt (0);
}
count++;
if(filestring[count] == 0) {
}else{
Result += filestring[count].charCodeAt (0);
}
count++;
if(filestring[count] == 0) {
}else{
FormatType += filestring[count].charCodeAt (0);
}
count++;
if(filestring[count] == 0) {
}else{
FormatType += filestring[count].charCodeAt (0);
}
var Format =''
switch(FormatType){
case 0: Format = " Format Standard";
break;
case 1: Format = " Format Optimised";
break;
case 2: Format = " Format Progressive";
break;
default:break;
}
var Qualities = [507,508,509,510,0,1,2,3,4,5,6,7,8];
for(var a =0;a<Qualities.length;a++){
if(Result == Qualities[a]){
alert(decodeURI(file.name)+" Save As, Quality " + a + Format);
return;
}
}
}
You might want to look at ExifTool at http://www.sno.phy.queensu.ca/~phil/exiftool/. It has been around a while and uses a command line application to edit image metadata and does a lot of other things as well.
So no way to do it without loading special software?
The problem is our machines are re-imaged every once in a while and special software on any machine but my own (and this script will not be deployed on my own workstation) is problematic. I need to stick with as-stock-as-possible for all such solutions.
So EXIF and Graphic Converter, unless part of the OS X install, will be a problem.
It is not so much that there is no way to do it, but rather, without the availability of a 3rd party program, you are pretty much stuck with creating your own script/tool to read and write the tags. Not impossible, but certainly time consuming. You may consider contacting Mr. Harvey (at the exiftool link above) about the possibility of obtaining some source code to get you started.
I caved. Wish EXIFtools was more like an AppleScript plugin (OSAX) so I could imbed them in my app, but I needed EXIFtools for another project, so in for a penny, in for a pound.
Just an annoying support problem is all. I wish tools like this came with the OS…y’know, the one most graphics people use.
You just need the put it and its files in the contents Resources of your Application bundle and point to it.
I have done this in the past with the one from the install package. (use show package),
Or you can also download a zip of the files to put in your application Bundle. http://search.cpan.org/dist/Image-ExifTool/
Search this site on how to add to the bundle (pretty much drag and drop) and how to then point to the Exiftool file within it.
Since this is a FaceSpan project, I’ve contacted Mike Aldritt at Late Night Software to see if he can point me in the right direction for doing this. I suspect it’s alot like embedding JavaScripts (which I’ve done before in FaceSpan), I’m just not sure 100% how you embed what is a Perl script called by a terminal interface and still have it all work right.
I’m not distributing it for sale, just using it internally, so I didn’t think doing it was illegal. If I were to let this script loose in the wild, I’d of course contact the developer of EXIFTools and ask permission first.