Skip to main content
akmia51
Inspiring
April 17, 2021
Answered

I just thing to open only horizontal/vertical image from a folder

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 

This topic is closed to new replies. Start a new post to keep the conversation going.
Kukurykus
KukurykusCorrect answer
Legend
September 29, 2021

test image
check this link i have attached images and a screen recording video also


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())

15 replies

Kukurykus
Legend
April 17, 2021
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())
Translate
JJMack
Community Expert
Community Expert
April 17, 2021

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.

Translate
JJMack
akmia51
akmia51Author
Inspiring
September 30, 2021

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())

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
Translate
Abdul karim mia
JJMack
Community Expert
Community Expert
April 17, 2021

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. 

Translate
JJMack