Imager-Filter-Bakumatsu

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

Bakumatsu (幕末) is a name of the 19th century middle in the history
of Japan. ([http://en.wikipedia.org/wiki/Bakumatsu](http://en.wikipedia.org/wiki/Bakumatsu))
This filter makes the photograph old likes taken in the Bakumatsu era.

# FILTER

## bakumatsu

    $img->filter(type => 'bakumatsu');

- overlay\_image

        $img->filter(type => 'bakumatsu', overlay_image => '/foo/image.png');

    Overlay image to cover (it should have alpha channel). 
    default is: dist/share/BakumatsuTexture.png

# AUTHOR

Naoki Tomita <tomita@cpan.org>

# LICENSE

lib/Imager/Filter/Bakumatsu.pm  view on Meta::CPAN

use Imager;
use File::ShareDir 'dist_file';

my $texture = dist_file('Imager-Filter-Bakumatsu', 'BakumatsuTexture.png');

Imager->register_filter(
    type     => 'bakumatsu',
    callsub  => \&bakumatsu,
    callseq  => [],
    defaults => {
        overlay_image => $texture,
    },
);

sub bakumatsu {
    my %opt  = @_;
    my $self = delete $opt{imager};
    my $work = $self;
    
    $work = $work->convert(
        matrix => [

lib/Imager/Filter/Bakumatsu.pm  view on Meta::CPAN

    $work = $work->convert(
        matrix => [
            [ 1 / 4, 1 / 2, 1 / 8, 0 ],
            [ 1 / 4, 1 / 2, 1 / 8, 0 ],
            [ 1 / 4, 1 / 2, 1 / 8, 0 ],
        ],
    );
    
    $work->rubthrough(
        src => do {
            my $overlay = Imager->new;
               $overlay->read(file => $opt{overlay_image})
                or die $overlay->errstr;
            
            $overlay = $overlay->scale(
                xpixels => $work->getwidth,
                ypixels => $work->getheight,
                type    => 'nonprop'
            );
        },
    ) or die $work->errstr;
    
    $self->{IMG} = delete $work->{IMG};
}

lib/Imager/Filter/Bakumatsu.pm  view on Meta::CPAN

This filter makes the photograph old likes taken in the Bakumatsu era.

=head1 FILTER

=head2 bakumatsu

  $img->filter(type => 'bakumatsu');

=over 4

=item overlay_image

  $img->filter(type => 'bakumatsu', overlay_image => '/foo/image.png');

Overlay image to cover (it should have alpha channel). 
default is: dist/share/BakumatsuTexture.png

=back

=head1 AUTHOR

Naoki Tomita E<lt>tomita@cpan.orgE<gt>



( run in 1.409 second using v1.01-cache-2.11-cpan-7fcb06a456a )