Thanks Mike
It's working great, would it be possible to get the script to delete the text file when it's finished with it, also would it be possible to leave crop open?
Photo Mechanic's & Cropping
Photo Mechanic's & Cropping
Mike
I'm getting an error, when i was hoping I'd got the script working ok?
http://farm3.static.flickr.com/2207/235 ... 34e3_o.jpg ... 34e3_o.jpg
I'm getting an error, when i was hoping I'd got the script working ok?
http://farm3.static.flickr.com/2207/235 ... 34e3_o.jpg ... 34e3_o.jpg
Photo Mechanic's & Cropping
Try this. I made a few changes that you asked for to Patrick's code. It will now delete the bat and text file and report some errors. It also lets the user adjust the crop if wanted.
Code: Select allfunction main(){
var docRef = app.activeDocument;
// build batch file to extract data
var bat = new File(docRef.path +'/cropexif.bat');
bat.open('w');
bat.writeln('c:');
bat.writeln('cd '+ docRef.path.fsName) ;
bat.writeln('exiftool -s -S -CropTop -CropLeft -CropBottom -CropRight '+ docRef.name +' > '+ docRef.name +'.txt');
bat.writeln('exit');
bat.close();
// run batch file
bat.execute();
// read in result file
var crop = new File(docRef.path +'/'+ docRef.name +'.txt');
// need a delay or it won't work apparently
$.sleep(2000);
// delete bat file
bat.remove();
if(crop.exist == false){
alert('Can not fine text file');
return;
};
crop.open('r');
var bounds = crop.read();
crop.close();
crop.remove();
bounds = bounds.split('\n');
if(bounds.length != 5) {
alert('Problem with text file');
return;
};
// crop bounds from photo mechanic
var desc = new ActionDescriptor();
var desc1 = new ActionDescriptor();
desc1.putUnitDouble( charIDToTypeID( "Top " ), charIDToTypeID( "#Pxl" ), bounds[0] );
desc1.putUnitDouble( charIDToTypeID( "Left" ), charIDToTypeID( "#Pxl" ), bounds[1] );
desc1.putUnitDouble( charIDToTypeID( "Btom" ), charIDToTypeID( "#Pxl" ), bounds[2] );
desc1.putUnitDouble( charIDToTypeID( "Rght" ), charIDToTypeID( "#Pxl" ), bounds[3] );
desc.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Rctn" ), desc1 );
desc.putUnitDouble( charIDToTypeID( "Angl" ), charIDToTypeID( "#Ang" ), 0.000000 );
desc.putUnitDouble( charIDToTypeID( "Wdth" ), charIDToTypeID( "#Pxl" ), 0.000000 );
desc.putUnitDouble( charIDToTypeID( "Hght" ), charIDToTypeID( "#Pxl" ), 0.000000 );
desc.putUnitDouble( charIDToTypeID( "Rslt" ), charIDToTypeID( "#Rsl" ), 0.000000 );
executeAction( charIDToTypeID( "Crop" ), desc, DialogModes.ALL );
};
main();
Mike
Code: Select allfunction main(){
var docRef = app.activeDocument;
// build batch file to extract data
var bat = new File(docRef.path +'/cropexif.bat');
bat.open('w');
bat.writeln('c:');
bat.writeln('cd '+ docRef.path.fsName) ;
bat.writeln('exiftool -s -S -CropTop -CropLeft -CropBottom -CropRight '+ docRef.name +' > '+ docRef.name +'.txt');
bat.writeln('exit');
bat.close();
// run batch file
bat.execute();
// read in result file
var crop = new File(docRef.path +'/'+ docRef.name +'.txt');
// need a delay or it won't work apparently
$.sleep(2000);
// delete bat file
bat.remove();
if(crop.exist == false){
alert('Can not fine text file');
return;
};
crop.open('r');
var bounds = crop.read();
crop.close();
crop.remove();
bounds = bounds.split('\n');
if(bounds.length != 5) {
alert('Problem with text file');
return;
};
// crop bounds from photo mechanic
var desc = new ActionDescriptor();
var desc1 = new ActionDescriptor();
desc1.putUnitDouble( charIDToTypeID( "Top " ), charIDToTypeID( "#Pxl" ), bounds[0] );
desc1.putUnitDouble( charIDToTypeID( "Left" ), charIDToTypeID( "#Pxl" ), bounds[1] );
desc1.putUnitDouble( charIDToTypeID( "Btom" ), charIDToTypeID( "#Pxl" ), bounds[2] );
desc1.putUnitDouble( charIDToTypeID( "Rght" ), charIDToTypeID( "#Pxl" ), bounds[3] );
desc.putObject( charIDToTypeID( "T " ), charIDToTypeID( "Rctn" ), desc1 );
desc.putUnitDouble( charIDToTypeID( "Angl" ), charIDToTypeID( "#Ang" ), 0.000000 );
desc.putUnitDouble( charIDToTypeID( "Wdth" ), charIDToTypeID( "#Pxl" ), 0.000000 );
desc.putUnitDouble( charIDToTypeID( "Hght" ), charIDToTypeID( "#Pxl" ), 0.000000 );
desc.putUnitDouble( charIDToTypeID( "Rslt" ), charIDToTypeID( "#Rsl" ), 0.000000 );
executeAction( charIDToTypeID( "Crop" ), desc, DialogModes.ALL );
};
main();
Mike
Photo Mechanic's & Cropping
hi guys i see your working with exiftool and bat scripts. does any one know how to write a bat script to extract meta data from from files to a csv log?
Photo Mechanic's & Cropping
Hi
Would it be possible to get the script above converted to work with my MacBook Mac OS X 10.6.7 ?
Many Thanks
Would it be possible to get the script above converted to work with my MacBook Mac OS X 10.6.7 ?
Many Thanks