Plucene::SearchEngine::Index::Image - Backend for mining data about images


Plucene-SearchEngine-Index-Image documentation Contained in the Plucene-SearchEngine-Index-Image distribution.

Index


Code Index:

NAME

Top

Plucene::SearchEngine::Index::Image - Backend for mining data about images

DESCRIPTION

Top

Upon installation, this acts as a handler for images, using Image::Info to populate the following Plucene fields:

size

The dimensions of the image.

text

Any comments found in the image.

subtype

The type of image. (jpg, png, etc.)

created

A Plucene data field representing the last modified date encoded in the image itself.

SEE ALSO

Top

Plucene::SearchEngine::Index

AUTHOR

Top

Simon Cozens, <simon@cpan.org>

COPYRIGHT AND LICENSE

Top


Plucene-SearchEngine-Index-Image documentation Contained in the Plucene-SearchEngine-Index-Image distribution.

package Plucene::SearchEngine::Index::Image;
use strict;
use warnings;
use base 'Plucene::SearchEngine::Index::Base';
use Image::Info qw(image_info dim);
use Time::Piece;
use Date::Parse;

our $VERSION = '0.01';

__PACKAGE__->register_handler(qw( 
    image/bmp           .bmp 
    image/gif           .gif
    image/jpeg          jpeg jpg jpe
    image/png           png
    image/x-portable-bitmap     pbm
    image/x-portable-graymap    pgm
    image/x-portable-pixmap     ppm
    image/svg+xml           svg
    image/tiff          tiff tif
    image/x-xbitmap         xbm
    image/x-xpixmap         xpm
));

sub gather_data_from_file {
    my ($self, $filename) = @_;
    my $info = image_info($filename);
    return if $info->{error};
    $self->add_data("size", "Text", scalar dim($info));
    $self->add_data("text", "UnStored", $info->{Comment});
    $self->add_data("subtype", "Text", $info->{file_ext});
    $self->add_data("created", "Date", Time::Piece->new(str2time($info->{LastModificationTime})));
}

1;
__END__
# Below is stub documentation for your module. You'd better edit it!