Image directories

With the following code, we created a montage of the images contained in the  directories. Each directory has then a quick visual overview, very much like a contact sheet.

import os
montagesdir="/home/nicolas/Public/kurenniemi-erkki/montages"
i=0
j=20
for root, dirs, files in os.walk("."):
    print root, "dirs", dirs
    if i>1:
        for d in dirs:
            print os.getcwd()
            path = os.path.join(root, d)
            thumbpath=path+'/thumbs__'
            os.system('mkdir "' + thumbpath + '"')
            os.system('cp -rvp '+path.replace(' ','\ ')+'/*.JPG "' + thumbpath + '"')
            os.system('mogrify -resize 640 ' + thumbpath.replace(' ','\ ')+'/*')
            os.system('montage ' + thumbpath.replace(' ','\ ') + '/* '+montagesdir+'/'+ str(j)+ '.jpg')
            os.system('rm -rf "' + thumbpath + '"')
            j+=1
#    else:
#        break
    i+=1
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *