##
##  wml::des::lowsrc - Create Image and LOWSRC-Attribute for IMG-Tag
##  Copyright (c) 1997-2001 Ralf S. Engelschall, All Rights Reserved. 
##

#use wml::std::tags

<define-tag lowsrc>
<perl>
{
    my $src;
    <perl:assign:sq $src>%0</perl:assign:sq>
    my $lowsrc = $src;
    $lowsrc =~ s|\.([^.]+)$|.lowsrc.$1|;
    if (not -f $src) {
        print STDERR "wml::des::lowsrc, Error: Image `$src' not found\n";
    }
    my $skip = 0;
    if (-f $lowsrc) {
        $skip = 1 if ((stat($src))[9] <= (stat($lowsrc))[9]);
    }
    if (not $skip) {
        my $error = `convert -monochrome $src $lowsrc`;
        if ($? >> 8) {
            print STDERR "** wml::des::lowsrc:\n$error";
            exit(1);
        }
    }
    <perl:print> lowsrc="$lowsrc"</perl:print>
}
</perl>
</define-tag>

##EOF##
