import exifread import os import pandas as pd # Get list of photos photodir = 'Yigo_Palms_2015-01-04_0/' filelist = os.listdir(photodir) filelist # Get date and time for each photo from EXIF dt_list = [] for fn in filelist: path_name = photodir + fn # Open image file for reading (binary mode) f = open(path_name, 'rb') tags = exifread.process_file(f) dt = str(tags['EXIF DateTimeOriginal']) dt_list.append(dt) dt_list # Create a data frame and sort by time stamp df = pd.DataFrame() df['fn'] = filelist df['dt'] = dt_list df.sort('dt', inplace=True) df # Write a TeX file tex = r''' \documentclass[landscape,english]{scrartcl} \usepackage[T1]{fontenc} \usepackage[latin9]{inputenc} \usepackage{graphicx} \usepackage{babel} \begin{document} \title{Yigo Palms} \author{Aubrey Moore} \maketitle ''' for index, row in df.iterrows(): s = r''' \pagebreak{} \begin{figure} \includegraphics[width=1\textwidth,height=0.9\textheight,keepaspectratio]{%s%s} \caption{%s} \end{figure} ''' s = s % (photodir, row['fn'], row['dt']) tex += s tex += r'\end{document}' f = open('YigoPalmAlbum.tex', 'w') f.write(tex) f.close() # Generate a PDF version of the album (batchmode used to suppress output to this notebook) !pdflatex -interaction=batchmode YigoPalmAlbum.tex # Compress the PDF (from abot 80 Mb to about 2 Mb) !gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=YigoPalmAlbumC.pdf YigoPalmAlbum.pdf # Delete the bloated version of the PDF %rm YigoPalmAlbum.pdf