Changeset 21343


Ignore:
Timestamp:
12/14/09 14:47:41 (11 years ago)
Author:
kjdon
Message:

moved disable_pharos_imageis option into PharosImagePlugin. new option pharos_imageis_index thumbnail/screenview/original to determine which file to index

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gs3-extensions/pharos-imageis/trunk/perllib/plugins/PharosImagePlugin.pm

    r21316 r21343  
    3838}
    3939
     40my $index_on_list =
     41    [ { 'name' => "original",
     42        'desc' => "the original full sized file (will convert to jpg if necessary)" },
     43      { 'name' => "screenview",
     44        'desc' => "The screenview sized image (jpg screenview images will be created)" },
     45      { 'name' => "thumbnail",
     46        'desc' => "The thumbnail image (jpg thumbnails will be created)" } ];
     47
     48
    4049my $arguments = [
     50         { 'name' => "disable_pharos_imageis",
     51           'desc' => "Switch off the image similarity indexing",
     52           'type' => "flag",
     53           'reqd' => "no" },
     54         { 'name' => "pharos_imageis_index",
     55           'desc' => "Which size image files to index",
     56           'type' => "enum",
     57           'deft' => "thumbnail",
     58           'list' => $index_on_list,
     59           'reqd' => "no"}
    4160         ];
    4261
    4362my $options = { 'name' => "PharosImagePlugin",
    44         'desc' => "{PharosImagePlugin.desc}",
     63        'desc' => "Image Plugin that also does Pharos Image Similarity Indexing",
    4564        'abstract' => "no",
    4665        'inherits' => "yes",
     
    5877    my $self = new ImagePlugin($pluginlist, $inputargs, $hashArgOptLists);
    5978
     79    if ($self->{'disable_pharos_imageis'}) {
     80    # pharos disabled, don't care about args
     81    return bless $self, $class;
     82    }
     83   
     84    # we want imageconverter to store the paths to thumbnails etc so we can use them later.
     85    $self->{'store_file_paths'} = 1;
     86    # check args
     87    if ($self->{'pharos_imageis_index'} eq "thumbnail") {
     88    # thumbnails
     89    if ($self->{'create_thumbnail'} eq "false") {
     90        print STDERR "Pharos Indexing set to index thumbnails, switching on -create_thumbnail\n";
     91        $self->{'create_thumbnail'} = "true";
     92    }
     93    if ($self->{'thumbnailtype'} !~ /^jpe?g$/i) {
     94        print STDERR "Pharos Indexing set to index thumbnails, setting thumbnailtype to jpg\n";
     95        $self->{'thumbnailtype'} = "jpg";
     96    }
     97    } elsif ($self->{'pharos_imageis_index'} eq "screenview") {
     98    # screenview
     99    if ($self->{'create_screenview'} eq "false") {
     100        print STDERR "Pharos Indexing set to index screenview, switching on -create_screenview\n";
     101        $self->{'create_screenview'} = "true";
     102    }
     103    if ($self->{'screenviewtype'} !~ /^jpe?g$/i) {
     104        print STDERR "Pharos Indexing set to index screenview, setting screenviewtype to jpg\n";
     105        $self->{'screenviewtype'} = "jpg";
     106    }
     107   
    60108
     109    } else {
     110    # originals
     111    if (!$self->{'converttotype'} || $self->{'converttotype'}!~ /^jpe?g$/i) {
     112        print STDERR "Pharos Indexing set to index original images, setting  -converttotype to jpg\n";
     113        $self->{'converttotype'} = "jpg";
     114    }
     115   
     116    }
    61117    return bless $self, $class;
    62118
     
    69125
    70126    $self->SUPER::init(@_);
    71     $self->PharosImageIndexer::init();
     127    $self->PharosImageIndexer::init() unless $self->{'disable_pharos_imageis'};
    72128
     129    if (!$self->{'pharos_available'}) {
     130    $self->{'disable_pharos_imageis'} = 1; # set this to one so we don't call the functions all the time and get lots of warnings
     131    }
    73132}
    74133
     
    78137   
    79138    $self->SUPER::remove_all(@_);
    80     $self->PharosImageIndexer::remove_all(@_);
     139    $self->PharosImageIndexer::remove_all(@_) unless $self->{'disable_pharos_imageis'};
    81140   
    82141}
     
    87146    return undef if (!$self->can_process_this_file($file));
    88147   
    89     $self->PharosImageIndexer::remove_one(@_);
     148    $self->PharosImageIndexer::remove_one(@_) unless $self->{'disable_pharos_imageis'};
    90149    return $self->SUPER::remove_one(@_);
    91150   
     
    97156    # options??
    98157    my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
    99     $self->pharos_index_image(&util::filename_cat($base_dir, $file), $doc_obj);
     158    return if $self->{'disable_pharos_imageis'};
     159    if ($self->{'pharos_imageis_index'} eq "thumbnail" && -e $self->{'thumb_file'} ) {
     160    print STDERR "indexing thumbnail $self->{'thumb_file'}\n";
     161    $self->pharos_index_image($self->{'thumb_file'}, $doc_obj);
     162    } elsif ($self->{'pharos_imageis_index'} eq "screenview" && -e $self->{'screen_file'}) {
     163    print STDERR "indexing screenview $self->{'screen_file'}\n";
     164    $self->pharos_index_image($self->{'screen_file'}, $doc_obj);
     165    }
     166    elsif (defined $self->{'orig_file'} && -e $self->{'orig_file'}) {
     167    print STDERR "indexing converted original $self->{'orig_file'}\n";
     168    $self->pharos_index_image($self->{'orig_file'}, $doc_obj);
     169    }
     170    else {
     171    # fall back option, index the original
     172    print STDERR "indexing original &util::filename_cat($base_dir, $file)\n";
     173    $self->pharos_index_image(&util::filename_cat($base_dir, $file), $doc_obj);
     174    }
    100175}
    101176
Note: See TracChangeset for help on using the changeset viewer.