<opt quiet>
<file template="album.htt">

<blockdef name="page">
  <if not pagectr><set pagectr="0" global></if>
  <inc pagectr global>
  <block name="page$pagectr" expand global><use block noexpand></block>
  <set pchap$pagectr="$chapterctr" global>
</blockdef>

<def name="resizeimg" option="src prefix size quality">
   <if not quality><set quality="70"></if>
   <file execute="test -r $prefix$src || convert -resize $size -quality $quality $src $prefix$src" redirect>
</def>

<def name="image" option="src subtitle">
  <if not subtitle><set subtitle=""></if>
  <page expand>
    
    <quote resizeimg src="$src" prefix=sml size="800x600">
    
    <if not subtitle="">
<use subtitle noexpand></if>
    
  </page>
  <set thumb${pagectr}="$src" global>
</def>

<def name="thumbnails" option="chapter">
  <set pg="${chpage${chapter}}"
  <set col=0>

  <while pchap${pg}=$chapter>
    <if thumb${pg}>
      <if col=6>
<set col=0></if>
      <inc col>
      <if col=1></if>
      <resizeimg src="${thumb$pg}" prefix=tn  size="133x100" quality=70>
       
    </if>
    <inc pg>
  </while>

</def>

<def name="chapter" option="title">
  <if not chapterctr><set chapterctr="0" global></if>
  <inc chapterctr global>
  <set chtitle${chapterctr}=${title} global>
  <page expand>

<use title noexpand>

    <quote thumbnails chapter=${chapterctr}>
  </page>
  <set chpage${chapterctr}=${pagectr} global>
</def>
