Image::Processor::Store::File - Perl extension for Woking with disk stores of images


Image-Processor documentation Contained in the Image-Processor distribution.

Index


Code Index:

NAME

Top

Image::Processor::Store::File - Perl extension for Woking with disk stores of images

SYNOPSIS

Top

  use Image::Processor::Store::File;
  Part of the Image::Processor module

DESCRIPTION

Top

Image::Processor::Store::File

EXPORT

None this is all OOP.

METHODS

    'create_path' - creates the entire path passed to it if it doesn't exist

    'get_image_list' - reads a directory for images

    'image_list' - used internally to set the image list

    'determine_source' - this adds "/PICTURES" on the end of the source if the
                'cdrom' method is set.

    'extension' - used for the regular expression that reads the list of images
    in the source directory. defaults to jpg|gif

AUTHOR

Top

Aaron Johnson <solution@gina.net>

SEE ALSO

Top

perl.


Image-Processor documentation Contained in the Image-Processor distribution.

package Image::Processor::Store::File;

use strict;
use base ( 'Image::Processor::Base' );

use File::Path;
use File::Copy;

# handles all the File interaction

sub create_path {
    my ($self,$dir) = @_;
    print "Creating dir '$dir'\n\n" if (!-d $dir);
    my $print_dirs = 0;
    my $perms      = 0777;
    mkpath( "$dir", $print_dirs, $perms ) 
	or return "Can't create directory '$dir': $!";
}

sub extension {
    my ($self,$set) = @_;
    return $self->{'extension'} if !$set;
    $self->{'extension'} = $set;
}

sub get_image_list {
    my ($self,$set) = @_;
    chdir($self->source_directory());
    my $expression = $self->extension() || "jpg|gif";
    # get list of picture
    opendir(DIR, $self->source_directory());
    my @files;    
    @files = grep { /\.($expression)$/i } readdir(DIR);

    closedir(DIR);
    $self->image_list(\@files);
    # $self->image_list([ <*.jpg> ]);

}

sub image_list {
    my ($self,$set) = @_;
    return $self->{'image_list'} if !$set;
    $self->{'image_list'} = $set;
}

sub determine_source {
    my ($self) = @_;
    my $source_dir = $self->cdrom() . "/PICTURES" if $self->cdrom();

    
    $self->source_directory($source_dir);
}


1;

__END__
# Below is stub documentation for your module. You better edit it!