# imstack profile for www gallery
{
    # option declaration
    'opt' => { 'author' => undef,
               'logo' => undef,
           },

    # help
    'help' => "Profile options:\n" .
        "    author          - author of the photo, saved into EXIF\n" .
        "    logo            - image of logo, put to the image corner\n",
    
    # prepare( $subprofile, $opt )
    'prepare' => sub {
        my ($p,$o) = @_;

        $p->{'tn'} and return; # nothing to do for thumbnails;

        defined( $o->{'author'} ) and 
            $p->{'exif'}{'Author'} = $o->{'author'};

        defined( $o->{'logo'} ) and 
            push @{$p->{'convert'}},
            '-draw', "gravity SouthEast image over 10,10 52,16 $o->{'logo'}",
    },

    'sub' =>
        [
         # subprofile for different image sizes
         { 
             # [ w, h, keep-exif(0/1) ]
             'sizes' => [ [1340, 900, 0],
                          [ 964, 618, 0],
                          [ 740, 450, 0] ],
             
             # sub( $dirpart, $filepart, $w, $h )
             'dir_file' => sub { 
                 my ($d,$f,$w,$h) = @_; 
                 my @ret = ( sprintf( "$d/%.4i", $w ), "$f.jpg" );
           
                 $f =~ /x$/ and push @ret, $w*10;
                 return @ret;
             },
             
             'convert' => [ '-quality', '85' ],
         },
         
         # subprofile for thumbnails
         { 
             'tn' => 1,

             # [ w, h, keep-exif(0/1) ]
             'sizes' => [ [ 150, 150, 0],
                          [ 300, 300, 0] ],
             
             # sub( $dirpart, $filepart, $w )
             'dir_file' => sub { 
                 my ($d,$f,$w,$h) = @_; 
                 my @ret = ( sprintf( "$d/%.4i", $w ), "$f.jpg" );
                 $f =~ /x$/ and push @ret, $w*6, 0.7*$h;
                 return @ret;

                 return ( sprintf( "$d/%.4i", $w ), "$f.jpg" );
             },
             
             'convert' => [ '-quality', '75' ],
         }
         ],
};
