Skip to main content
akmia51
Inspiring
April 17, 2021
Answered

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

  • April 17, 2021
  • 2 replies
  • 4634 views
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 has been closed for replies.
Correct answer Kukurykus

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

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

JJMack
Kukurykus
Legend
April 18, 2021

try...catch statement is also necessary, because ExternalObject is not always reliable.

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. 

JJMack