Copy link to clipboard
Copied
var fol=Folder.selectDialog('Select a folder With Mixed Image horizontal And vertical Image');
function horizontal(fol){
var files = fol.getFiles( //get only horizontal image---------
);
for ( i = 0; i < files.length; i++) {
open(i);
}
}
function vertical(fol){
var files = fol.getFiles( //get only vertical image---------
);
for ( i = 0; i < files.length; i++) {
open(i);
}
}
i don't know how can I do id
If normally the orienation of your images is horizontal then use:
function gF(v) {
if (!ExternalObject.AdobeXMPScript)
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript')
xmp = new XMPFile(v.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ).getXMP()
return /1|3/.test(xmp.getProperty(XMPConst.NS_TIFF, 'Orientation')) // or use 6|8
}
fls = Folder.selectDialog().getFiles(gF); while(fls.length) open(fls.shift())
Copy link to clipboard
Copied
You would to get all the Image files names then filter the file list be processing the file meta data. Even the file filtering that can be done on windows is only relative to file types not image attributes. getfiles gets you a list of file names. On Mac you even have to code a filter to filter file types.
Copy link to clipboard
Copied
function gF(v) {
if (!ExternalObject.AdobeXMPScript)
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript'),
gP = function(v) {return xmp.getProperty(XMPConst.NS_EXIF, 'Pixel' + v + 'Dimension')}
xmp = new XMPFile(v.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ).getXMP()
return eval("gP('X') " + lessthanorgreaterthancharacterassignedearlier + " gP('Y')")
}
lessthanorgreaterthancharacterassignedearlier = ['<', '>'][0]
fls = Folder.selectDialog().getFiles(gF); while(fls.length) open(fls.shift())
Copy link to clipboard
Copied
Had to add a try catch to ignore errors that happen in the gF function when the selected folder has folders and perhaps some none image files.
Copy link to clipboard
Copied
try...catch statement is also necessary, because ExternalObject is not always reliable.
Copy link to clipboard
Copied
can you just check it bkc its not working at all
Copy link to clipboard
Copied
Now it's set to open vertical images. Change 0 to 1 to open only horizontal ones.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
For me all works. Attach some of your jpgs for me so I'll try them on my side.
Copy link to clipboard
Copied
For me all works. Attach some of your jpgs for me so I'll try them on my side.
By @Kukurykus
Some files do not contain metadata at all, for example PNG, BMP and others.
Copy link to clipboard
Copied
I use this script for .jpg format, for others I sometimes read binaries.
Copy link to clipboard
Copied
test image
check this link i have attached images and a screen recording video also
Copy link to clipboard
Copied
If normally the orienation of your images is horizontal then use:
function gF(v) {
if (!ExternalObject.AdobeXMPScript)
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript')
xmp = new XMPFile(v.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ).getXMP()
return /1|3/.test(xmp.getProperty(XMPConst.NS_TIFF, 'Orientation')) // or use 6|8
}
fls = Folder.selectDialog().getFiles(gF); while(fls.length) open(fls.shift())
Copy link to clipboard
Copied
its working but some time its doing misteks like if the image dont have XMP data
like the attached image
i just think like this now
var files = File.openDialog ("Select mixed Image", "", true);
var potrait=[]
var hor=[]
for(f=0;f<files.length;f++){
if(check (files[f])){potrait.push (files[f])}else{hor.push (files[f])}
}
function check (fil){
// it should not check XMP and it should not open file in photoshop
if(fil is potrait ){
return true;
}else {return false;}
}
// then we can get all potrait and hor.. file separet
Copy link to clipboard
Copied
If the images with no XMP are landscape too then instead of appropriate line use:
return !(ornttn = xmp.getProperty(XMPConst.NS_TIFF, 'Orientation')) || /1|3/.test(ornttn)
Copy link to clipboard
Copied
Kukurykus
I find this script fantastic
Thank you