%%
%% This is file `photoprint.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% photoprint.dtx  (with options: `class')
%% 
 % ###################################################################
 %
 %  FILE: "photoprint.dtx"
 %                                    created: 2003-03-03 13:53:42
 %                                last update: 2006-09-28 17:06:43
 %  Author: Fr\'ed\'eric Boulanger
 %  E-mail: Frederic.Boulanger@supelec.fr
 %    mail: Sup\'elec - Service Informatique
 %          3 rue Joliot-Curie, F-91192 Gif-sur-Yvette cedex
 %     www: http://wwwsi.supelec.fr/fb/
 %
 %  Description:
 %
 %  Photoprint is a document class to print photographs and contact
 %  sheets. A file named "photoprint.job" should contain one line
 %  for each file to print. The line should contains the name of the
 %  picture file which may be followed by a '*' character and the
 %  number of copies of this picture to print. If the "*<num>" part
 %  is omitted, one copy of the picture will be printed.
 %  When printing contact sheets, the number of copies is ignored,
 %  and each picture in the file is shown once in the contact sheet.
 %
 %  Options:
 %    cropmarks     print crop marks to help cut the pictures
 %
 %    whitemargins  use the smallest margin of the printable area
 %                  as the size of the white space left around pictures.
 %                  This allows to have an even white border around
 %                  the pictures after they are cut.
 %
 %    fullpictures  prevents cropping when the aspect ratio of the
 %                  picture is not the same as the aspect ratio of the
 %                  printing slot on the paper. When this option is
 %                  set, the picture is scaled down so that it fits
 %                  entirely in the slot, with white margins.
 %                  The default behavior is to crop the picture so
 %                  that there is no white band aside it.
 %
 %    landscape     use paper in landscape orientation.
 %
 %    showdate      print the date in the lower right corner of the pictures.
 %                  The printed date is read from a map file which keeps
 %                  information about pictures.
 %                  The file should be named !Name_Map.can or !Name_Map.mav.
 %                  Each line should contain 4 items between braces :
 %                    {<seconds>} {<filename>} {<original>} {<date>}
 %                  Only the <filename> and the <date> are used by photoprint.
 %                  <seconds>  is the number of seconds since january 1 1904
 %                             (the epoch on the Macintosh)
 %                  <filename> is the file name of the picture
 %                  <original> is the file name of the original picture as taken
 %                             by the camera
 %                  <date>     is the date and time at which the picture was
 %                             taken in ISO format : YYYY-MM-DDThh:mm:ssZ, where
 %                             YYYY is the year, MM the month (1-12), DD the day
 %                             of month (1-31), hh the hour (0-23), mm the
 %                             minutes (0-59) and ss is the seconds (0-59).
 %
 %  Commands:
 %    \photodir{<directory path>}
 %                          sets the name of the directory in which
 %                          the photos will be searched. If not used,
 %                          the photos are searched in the current
 %                          directory. <directory path> must end with
 %                          a path separator ('/' on Unix, '\' on
 %                          Windows).
 %
 %    \photosperline{<num>} sets the number of photos which will
 %                          appear on the same line. Default value
 %                          is two.
 %
 %    \photospercol{<num>}  sets the number of photos which will
 %                          appear on the same column. Default value
 %                          is two.
 %
 %    \photopaper{<top>}{<left>}{<bottom>}{<right>}
 %                          sets the margins of the printable area on
 %                          the paper. Defaults to 0.5cm 0.5cm 1cm 0.5cm
 %                          which is OK for most inkjet printers
 %                          (tested with a Canon S800).
 %                          <top>, <left>, <bottom> and <right> are
 %                          relative to the portrait orientation of the
 %                          paper. If the document is printed in
 %                          landscape mode, <top> will be the left
 %                          margin and so on, so you don't have to
 %                          care about printing orientation when you
 %                          define the printing area of your printer.
 %
 %    \printphotos[<job-file>]
 %                          prints the photographs as described in
 %                          <job-file>. <job-file> is an optional
 %                          argument and defaults to "photoprint.job".
 %
 %    \datecolor{<color>}   sets the color used to print the date on pictures
 %                          when the showdate option is active. It defaults
 %                          to black.
 %
 %    \datestyle{<style>}   sets the style used to print the date on pictures
 %                          when the showdate option is active. <style> should be
 %                          a series of text-style declarations. The default is:
 %                          \sffamily\small
 %
 %    \infostyle{<style>}   sets the style used to print information about
 %                          pictures on the contact sheets (date and name).
 %                          <style> should be a series of text-style
 %                          declarations. The default is: \sffamily\footnotesize
 %
 %    \contactsheet[<job-file>]
 %                          prints the contact sheets for the
 %                          photographs listed in <job-file>.
 %                          Numbers of copies in <job-file> are ignored.
 %                          Photos are printed 5 by line and 4 by
 %                          column, so a landscape orientation is
 %                          recommended.
 %                          If the \cstitle macro is defined, it will
 %                          be used as the title of the contact sheet.
 %
 %    \photohmargin{<length>} sets the white space left horizontaly
 %                            around pictures. Consecutive pictures
 %                            will be separated by twice this length.
 %
 %    \photovmargin{<length>} sets the white space left verticaly
 %                            around pictures. Consecutive pictures
 %                            will be separated by twice this length.
 %
 %    \photomargins{<length>} sets the white space left in both directions
 %                            around pictures. Consecutive pictures
 %                            will be separated by twice this length.
 %
 %  History
 %
 %  modified   by  rev reason
 %  ---------- --- --- -----------
 %  2002-09-30 FBO 1.0 original
 %  2002-10-11 FBO 1.1 added support for .JPG, show photo dates
 %  2004-02-22 FBO 1.2 do not use geometry any longer
 %  2006-09-28 FBO 1.3 added \photodir macro to set picture folder.
 % ###################################################################
 %%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{photoprint}
              [2004/02/22 v1.2]

\RequirePackage{ifthen}
\newboolean{photo@cropmarks}
\newboolean{photo@whitemargins}
\newboolean{photo@landscapepaper}
\newboolean{photo@fullpictures}
\newboolean{photo@showdate}

\DeclareOption{cropmarks}{\setboolean{photo@cropmarks}{true}}
\DeclareOption{whitemargins}{\setboolean{photo@whitemargins}{true}}
\DeclareOption{fullpictures}{\setboolean{photo@fullpictures}{true}}
\DeclareOption{showdate}{\setboolean{photo@showdate}{true}}
\DeclareOption{landscape}{%
  \setboolean{photo@landscapepaper}{true}%
  \PassOptionsToClass{\CurrentOption}{article}%
  \PassOptionsToPackage{\CurrentOption}{geometry}%
}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\ProcessOptions\relax

\LoadClass{article}
\RequirePackage{calc}
\RequirePackage{graphicx}
\RequirePackage{color}
\RequirePackage[T1]{fontenc}

\DeclareGraphicsRule{.JPG}{jpg}{*}{}

\setlength{\parindent}{0pt}
\pagestyle{empty}

\newcommand*{\photo@dir}{}

\newcommand*{\photodir}[1]{%
  \renewcommand*{\photo@dir}{#1}%
}

\newcounter{photo@perline}
\newcounter{photo@percol}

\newcommand{\photosperline}[1]{%
  \setcounter{photo@perline}{#1}%
}

\newcommand{\photospercol}[1]{%
  \setcounter{photo@percol}{#1}%
}

\newcommand{\photo@date@color}{black}
\newcommand{\datecolor}[1]{%
  \renewcommand{\photo@date@color}{#1}%
}

\newcommand{\photo@date@style}{\sffamily\small}
\newcommand{\datestyle}[1]{%
  \renewcommand{\photo@date@style}{#1}%
}

\newcommand{\photo@info@style}{\sffamily\footnotesize}
\newcommand{\infostyle}[1]{%
  \renewcommand{\photo@info@style}{#1}%
}

\newlength{\photo@top}
\newlength{\photo@left}
\newlength{\photo@bottom}
\newlength{\photo@right}

\newcommand{\photopaper}[4]{% top left bottom right
  \setlength{\photo@top}{#1}
  \setlength{\photo@left}{#2}
  \setlength{\photo@bottom}{#3}
  \setlength{\photo@right}{#4}
  \calc@photomargins
}

\newboolean{photo@inpicture}
\setboolean{photo@inpicture}{false}

\newcounter{photo@num}
\newcounter{photo@firstnum}

\newread\photo@list

\newcommand{\printphotos}[1][photoprint.job]{%
  \calc@photodim
  \ifthenelse{\boolean{photo@showdate}\OR\boolean{photo@contactsheet}}{%
    \IfFileExists{!Name_Map.can}{%
      \photo@read@map[!Name_Map.can]%
    }{%
      \IfFileExists{!Name_Map.mav}{%
        \photo@read@map[!Name_Map.mav]%
      }{%
        \ClassWarningNoLine{photoprint}{%
          No map file were found. Dates won't be shown.
        }%
        \setboolean{photo@showdate}{false}%
      }%
    }%
  }{}%
  \setcounter{photo@num}{0}%
  \immediate\openin\photo@list=#1
  \photo@read
  \ifthenelse{\boolean{photo@inpicture}}{%
    \photo@drawticks
    \end{picture}%
  }{}%
}

\newboolean{photo@contactsheet}

\newcommand{\contactsheet}[1][photoprint.job]{%
  \setboolean{photo@contactsheet}{true}%
  \setboolean{photo@whitemargins}{false}%
  \setboolean{photo@cropmarks}{false}%
  \ifthenelse{\boolean{photo@landscapepaper}}{%
    \addtolength{\photo@right}{1cm}%
    \addtolength{\photo@left}{0.5cm}%
  }{%
    \addtolength{\photo@top}{1cm}%
    \addtolength{\photo@bottom}{0.5cm}%
  }%
  \calc@photomargins
  \photosperline{5}%
  \photospercol{4}%
  \photohmargin{2mm}%
  \photovmargin{4mm}%
  \printphotos[#1]%
}

\newlength{\photo@unitlength}
\newcounter{photo@unitconv}
\setlength{\photo@unitlength}{0.1mm}
\setcounter{photo@unitconv}{\photo@unitlength}

\newlength{\photo@tmplen}
\newcounter{photo@hgap}
\newcounter{photo@vgap}

\newcommand{\photohmargin}[1]{%
  \setlength{\photo@tmplen}{#1}%
  \setcounter{photo@hgap}{\photo@tmplen / \value{photo@unitconv}}%
}

\newcommand{\photovmargin}[1]{%
  \setlength{\photo@tmplen}{#1}%
  \setcounter{photo@vgap}{\photo@tmplen / \value{photo@unitconv}}%
}

\newcommand{\photomargins}[1]{%
  \photovmargin{#1}%
  \photohmargin{#1}%
}

\photomargins{0pt}

\newlength{\photo@minmargin}

\newcommand{\calc@photomargins}{%
  \setlength{\headheight}{0pt}%
  \setlength{\headsep}{0pt}%
  \setlength{\footskip}{0pt}%
  \ifthenelse{\boolean{photo@landscapepaper}}{
    \setlength{\topmargin}{\photo@right-1in}%
    \setlength{\textheight}{\paperheight-\photo@right-\photo@left}%
    \setlength{\oddsidemargin}{\photo@top-1in}%
    \setlength{\evensidemargin}{\photo@top-1in}%
    \setlength{\textwidth}{\paperwidth-\photo@top-\photo@bottom}%
  }{
    \setlength{\topmargin}{\photo@top-1in}%
    \setlength{\textheight}{\paperheight-\photo@top-\photo@bottom}%
    \setlength{\oddsidemargin}{\photo@left-1in}%
    \setlength{\evensidemargin}{\photo@left-1in}%
    \setlength{\textwidth}{\paperwidth-\photo@left-\photo@right}%
  }
  \setlength{\photo@minmargin}{\photo@top}%
  \ifthenelse{\photo@left < \photo@minmargin}{%
    \setlength{\photo@minmargin}{\photo@left}%
  }{}%
  \ifthenelse{\photo@bottom < \photo@minmargin}{%
    \setlength{\photo@minmargin}{\photo@bottom}%
  }{}%
  \ifthenelse{\photo@right < \photo@minmargin}{%
    \setlength{\photo@minmargin}{\photo@right}%
  }{}%
}

\newcounter{paper@width}
\newcounter{paper@height}
\newcounter{photo@width}
\newcounter{photo@height}

\newcounter{photo@landscape}

\newcounter{photo@x}
\newcounter{photo@y}
\newcounter{photo@line}
\newcounter{photo@row}

\newcommand{\calc@photodim}{%
  \ifthenelse{\boolean{photo@whitemargins}}{%
    \photomargins{\photo@minmargin}%
  }{}%
  \setcounter{paper@width}{\textwidth / \value{photo@unitconv}}%
  \setcounter{paper@height}{\textheight / \value{photo@unitconv}}%
  %
  \setcounter{photo@width}{\value{paper@width}}%
  \addtocounter{photo@width}{-2*(\value{photo@perline}-1)*\value{photo@hgap}}
  \setcounter{photo@width}{\value{photo@width}/\value{photo@perline}}%
  %
  \setcounter{photo@height}{\value{paper@height}}%
  \addtocounter{photo@height}{-2*(\value{photo@percol}-1)*\value{photo@vgap}}
  \setcounter{photo@height}{\value{photo@height}/\value{photo@percol}}%
  %
  \ifthenelse{\value{photo@width}>\value{photo@height}}{%
    \setcounter{photo@landscape}{1}%
  }{%
    \setcounter{photo@landscape}{-1}%
  }%
  \setcounter{photo@x}{0}%
  \setcounter{photo@y}{\value{paper@height}-\value{photo@height}}%
  \setcounter{photo@line}{1}%
  \setcounter{photo@row}{1}%
}

\newcounter{photo@ex}

\def\parse@photo#1*#2\end{
  \gdef\photo@name{#1}%
  \if |#2|\relax
    \setcounter{photo@ex}{1}%
  \else
    \set@photo@ex#2%
  \fi
}

\def\set@photo@ex#1*{%
  \setcounter{photo@ex}{#1}%
}

\newcommand{\photo@read}{%
  \let\next\photo@read
  \ifeof\photo@list
    \immediate\closein\photo@list
    \let\next=\relax
  \else
    {%
      \endlinechar=-1
      \immediate\global\read\photo@list to \photo@name
    }%
    \if |\photo@name|
      \immediate\closein\photo@list
      \let\next=\relax
    \else
      \expandafter\parse@photo\photo@name*\end
      \ifphoto@contactsheet
        \setcounter{photo@ex}{1}%
      \else
        \message{Photo "\photo@name" x \thephoto@ex^^J}%
      \fi
      \stepcounter{photo@num}%
      \place@image
    \fi
  \fi
  \next
}

\newsavebox{\photo@box}
\newcounter{this@photo@width}
\newcounter{this@photo@height}
\newcounter{this@photo@landscape}
\newcounter{photo@angle}
\newcounter{photo@tmpcount}
\newcounter{photo@date@x}
\newcounter{photo@date@y}
\newcounter{photo@date@width}

\newlength{\photo@offset}
\newlength{\photo@width}
\newlength{\photo@height}
\newlength{\this@photo@width}
\newlength{\this@photo@height}
\newlength{\scaled@photo@width}
\newlength{\scaled@photo@height}

\newlength{\photo@trimleft}
\newlength{\photo@trimbot}
\newlength{\photo@trimright}
\newlength{\photo@trimtop}

\newboolean{photo@too@wide}

\newcommand{\place@image}{%
  \ifthenelse{\value{photo@ex}>0}{%
    \global\let\next@place=\place@image
    \ifthenelse{\(\value{photo@line}=1\)\and\(\value{photo@row}=1\)}{%
      \setlength{\unitlength}{\photo@unitlength}%
      \thispagestyle{empty}%
      \setcounter{photo@firstnum}{\value{photo@num}}%
      \begin{picture}(\value{paper@width},\value{paper@height})%
      \setboolean{photo@inpicture}{true}%
    }{}%
    \edef\photo@fname{\photo@dir\photo@name}%
    \savebox{\photo@box}{\includegraphics{\photo@fname}}%
    \setlength{\this@photo@width}{\wd\photo@box}%
    \setlength{\this@photo@height}{\ht\photo@box}%
    \setcounter{this@photo@width}{\this@photo@width / \value{photo@unitconv}}%
    \setcounter{this@photo@height}{\this@photo@height / \value{photo@unitconv}}%
    \ifthenelse{\this@photo@width > \this@photo@height}{%
      \setcounter{this@photo@landscape}{1}%
    }{%
      \setcounter{this@photo@landscape}{-1}%
    }%
    \setcounter{photo@tmpcount}{%
      \value{photo@landscape}*\value{this@photo@landscape}%
    }%
    \ifthenelse{\value{photo@tmpcount} < 0}{%
      \setcounter{photo@angle}{90}%
      \setcounter{photo@tmpcount}{\value{this@photo@width}}%
      \setcounter{this@photo@width}{\value{this@photo@height}}%
      \setcounter{this@photo@height}{\value{photo@tmpcount}}%
      \setlength{\photo@tmplen}{\this@photo@width}%
      \setlength{\this@photo@width}{\this@photo@height}%
      \setlength{\this@photo@height}{\photo@tmplen}%
    }{%
      \setcounter{photo@angle}{0}%
    }%
    \setlength{\unitlength}{\photo@unitlength}%
    \setlength{\photo@width}{\value{photo@width}\unitlength}%
    \setlength{\photo@height}{\value{photo@height}\unitlength}%
    %
    \setlength{\scaled@photo@width}{%
      \this@photo@width*\ratio{\photo@height}{\this@photo@height}%
    }%
    \setlength{\scaled@photo@height}{%
      \this@photo@height*\ratio{\photo@width}{\this@photo@width}%
    }%
    \ifthenelse{%
      \(\(\scaled@photo@width>\photo@width\)\AND\NOT\boolean{photo@fullpictures}\)
      \OR
      \(\(\scaled@photo@width<\photo@width\)\AND\boolean{photo@fullpictures}\)
    }{%
      \setboolean{photo@too@wide}{true}%
    }{%
      \setboolean{photo@too@wide}{false}%
    }
    \ifthenelse{\boolean{photo@too@wide}}{%
      % photo is too wide
      \setlength{\photo@offset}{%
        (\this@photo@width-\photo@width*\ratio{\this@photo@height}{\photo@height})/2
      }%
      \ifthenelse{\value{photo@angle}=0}{%
        \setlength{\photo@trimleft}{\photo@offset}%
        \setlength{\photo@trimbot}{0pt}%
      }{%
        \setlength{\photo@trimleft}{0pt}%
        \setlength{\photo@trimbot}{\photo@offset}%
      }%
    }{%
      % photo is too high
      \setlength{\photo@offset}{%
        (\this@photo@height-\photo@height*\ratio{\this@photo@width}{\photo@width})/2
      }%
      \ifthenelse{\value{photo@angle}=0}{%
        \setlength{\photo@trimleft}{0pt}%
        \setlength{\photo@trimbot}{\photo@offset}%
      }{%
        \setlength{\photo@trimleft}{\photo@offset}%
        \setlength{\photo@trimbot}{0pt}%
      }%
    }
    \setlength{\photo@trimright}{\photo@trimleft}%
    \setlength{\photo@trimtop}{\photo@trimbot}%
    \edef\photo@fname{\photo@dir\photo@name}%
    \put(\thephoto@x,\thephoto@y){%
      \includegraphics[%
        angle=\thephoto@angle,%
        trim=\photo@trimleft{} \photo@trimbot{} \photo@trimright{} \photo@trimtop{},%
        width=\photo@width,%
        height=\photo@height,%
        clip%
      ]{\photo@fname}}%
    \ifthenelse{\boolean{photo@contactsheet}}{%
      \put(\thephoto@x,\thephoto@y){\framebox(\thephoto@width,\thephoto@height){}}%
      \setcounter{photo@tmpcount}{\value{photo@y}-10}%
      \put(\thephoto@x,\thephoto@tmpcount){%
        \makebox(\thephoto@width,0)[ts]{%
          {\photo@info@style
           \photo@get@date{\photo@name}\hss
           % \photo@name may contain special characters
           \escapechar=-1{\expandafter\string\csname\photo@name\endcsname}\hss
          }\textsf{\thephoto@num}%
        }%
      }%
    }{%
      \ifthenelse{\boolean{photo@showdate}}{%
        \ifthenelse{\value{photo@angle}>0}{%
          \setcounter{photo@date@x}{\value{photo@x}+\value{photo@width}-20}%
          \setcounter{photo@date@y}{\value{photo@y}}%
          \setcounter{photo@date@width}{\value{photo@height}-20}%
          \put(\thephoto@date@x,\thephoto@date@y){%
            \rotatebox{90}{%
              \makebox(\value{photo@date@width},0)[br]{%
                \photo@date@style{%
                  \textcolor{\photo@date@color}{\photo@get@date{\photo@name}}%
                }%
              }%
            }%
          }%
        }{%
          \setcounter{photo@date@x}{\value{photo@x}}%
          \setcounter{photo@date@y}{\value{photo@y}+20}%
          \setcounter{photo@date@width}{\value{photo@width}-20}%
          \put(\thephoto@date@x,\thephoto@date@y){%
            \makebox(\value{photo@date@width},0)[br]{%
              \textcolor{\photo@date@color}{%
                \photo@date@style\photo@get@date{\photo@name}%
              }%
            }%
          }%
        }%
      }{}%
    }%
    %
    \addtocounter{photo@ex}{-1}%
    \stepcounter{photo@row}%
    \ifthenelse{\value{photo@row}>\value{photo@perline}}{%
      \setcounter{photo@row}{1}%
      \stepcounter{photo@line}%
      \setcounter{photo@x}{0}%
      \addtocounter{photo@y}{-\value{photo@height}}%
      \addtocounter{photo@y}{-2*\value{photo@vgap}}%
    }{%
      \addtocounter{photo@x}{\value{photo@width}}%
      \addtocounter{photo@x}{2*\value{photo@hgap}}%
    }%
    \ifthenelse{\value{photo@line}>\value{photo@percol}}{%
      \setcounter{photo@row}{1}%
      \setcounter{photo@line}{1}%
      \setcounter{photo@x}{0}%
      \setcounter{photo@y}{\value{paper@height}-\value{photo@height}}%
      \photo@drawticks
      \end{picture}\newpage
      \setboolean{photo@inpicture}{false}%
    }{}%
  }{%
    \let\next@place=\relax
  }%
  \next@place
}

\newcounter{photo@tick@x}
\newcounter{photo@tick@y}
\newcounter{photo@tick@line}
\newcounter{photo@tick@col}
\newcommand{\photo@drawticks}{%
  \ifthenelse{\boolean{photo@cropmarks}}{%
    \setcounter{photo@tick@col}{-1}%
    \setcounter{photo@tick@x}{-\value{photo@hgap}}%
    \setcounter{photo@tick@y}{-\value{photo@vgap}-1}%
    \whiledo{\value{photo@tick@col}<\value{photo@perline}}{%
      \put(\thephoto@tick@x, \thephoto@tick@y){\line(0,-1){40}}%
      \stepcounter{photo@tick@col}%
      \addtocounter{photo@tick@x}{2*\value{photo@hgap}}%
      \addtocounter{photo@tick@x}{\value{photo@width}}%
    }
    \setcounter{photo@tick@line}{-1}%
    \setcounter{photo@tick@x}{\value{paper@width}+\value{photo@hgap}+1}%
    \setcounter{photo@tmpcount}{-\value{photo@hgap}-1}%
    \setcounter{photo@tick@y}{-\value{photo@vgap}}%
    \whiledo{\value{photo@tick@line}<\value{photo@percol}}{%
      \put(\thephoto@tmpcount, \thephoto@tick@y){\line(-1,0){40}}%
      \put(\thephoto@tick@x, \thephoto@tick@y){\line(1,0){40}}%
      \stepcounter{photo@tick@line}%
      \addtocounter{photo@tick@y}{2*\value{photo@vgap}}%
      \addtocounter{photo@tick@y}{\value{photo@height}}%
    }%
    \setcounter{photo@tick@col}{-1}%
    \setcounter{photo@tick@x}{-\value{photo@hgap}}%
    \setcounter{photo@tick@y}{\value{paper@height} + \value{photo@vgap} + 1}%
    \whiledo{\value{photo@tick@col}<\value{photo@perline}}{%
      \put(\thephoto@tick@x, \thephoto@tick@y){\line(0,1){40}}%
      \stepcounter{photo@tick@col}%
      \addtocounter{photo@tick@x}{2*\value{photo@hgap}}%
      \addtocounter{photo@tick@x}{\value{photo@width}}%
    }%
  }{}%
  \ifthenelse{\boolean{photo@contactsheet}}{%
    \setcounter{photo@tick@y}{\value{paper@height}+50}%
    \setcounter{photo@tick@x}{0}%
    \put(\thephoto@tick@x,\thephoto@tick@y){\line(1,0){\value{paper@width}}}%
    \addtocounter{photo@tick@y}{10}%
    \put(\thephoto@tick@x,\thephoto@tick@y){\textsf{\textbf{\large PhotoIndex}}}%
    \put(\thephoto@tick@x,\thephoto@tick@y){%
      \makebox(\value{paper@width},0)[br]{%
        \textsf{\large\thephoto@firstnum{} -- \thephoto@num}%
      }%
    }%
    \put(\thephoto@tick@x,\thephoto@tick@y){%
      \makebox(\value{paper@width},0)[b]{%
        \textsf{\large\bfseries\csname cstitle\endcsname}%
      }%
    }%
  }{}%
}
%%
\newread\photo@mapfile

\newcommand{\photo@readmap@entry}{%
  \let\next@read=\relax
  \ifeof\photo@mapfile
    \immediate\closein\photo@mapfile
  \else
    {\endlinechar=-1\immediate\global\read\photo@mapfile to \photo@map@entry}%
    \if|\photo@map@entry|
      \immediate\closein\photo@mapfile
    \else
      \let\next@read=\photo@readmap@entry
      \photo@parse@entry\photo@map@entry
    \fi
  \fi
  \next@read
}

\newcommand{\photo@parse@entry}[1]{%
  \expandafter\photo@eval@entry#1
}

\newcommand{\photo@eval@entry}[4]{%
  \expandafter\expandafter\expandafter
  \def\expandafter\expandafter
    \csname #2\endcsname\expandafter{\photo@parse@isodate#4\end}%
}

\newcommand{\photo@parse@isodate}{}
\def\photo@parse@isodate#1T#2\end{%
  #1%
}

\newcommand{\photo@get@date}[1]{%
  \expandafter\csname#1\endcsname
}

\newcommand{\photo@read@map}[1][!Name_Map.can]{%
  \immediate\openin\photo@mapfile=#1
  \photo@readmap@entry
}

\photopaper{0.5cm}{0.5cm}{1cm}{0.5cm} % default for Canon S800
\photosperline{2}
\photospercol{2}
%% 
%%
%% End of file `photoprint.cls'.
