• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

Explorer ,
Apr 17, 2021 Apr 17, 2021

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 

Abdul karim mia
TOPICS
Actions and scripting

Views

1.1K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 29, 2021 Sep 29, 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())

Votes

Translate

Translate
Adobe
Community Expert ,
Apr 17, 2021 Apr 17, 2021

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. 

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2021 Apr 17, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 17, 2021 Apr 17, 2021

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.

JJMack

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 17, 2021 Apr 17, 2021

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 27, 2021 Sep 27, 2021

Copy link to clipboard

Copied

can you just check it bkc its not working at all 

Abdul karim mia

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 27, 2021 Sep 27, 2021

Copy link to clipboard

Copied

Now it's set to open vertical images. Change 0 to 1 to open only horizontal ones.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 27, 2021 Sep 27, 2021

Copy link to clipboard

Copied

I tried but not opened any images
Abdul karim mia

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

For me all works. Attach some of your jpgs for me so I'll try them on my side.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

quote

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

I use this script for .jpg format, for others I sometimes read binaries.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 29, 2021 Sep 29, 2021

Copy link to clipboard

Copied

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

Abdul karim mia

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 29, 2021 Sep 29, 2021

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 30, 2021 Sep 30, 2021

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
Abdul karim mia

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 30, 2021 Sep 30, 2021

Copy link to clipboard

Copied

LATEST

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)

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Sep 28, 2021 Sep 28, 2021

Copy link to clipboard

Copied

Kukurykus
I find this script fantastic
Thank you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines