Index: /gs3-extensions/pharos-imageis/trunk/perllib/plugins/PharosImagePlugin.pm
===================================================================
--- /gs3-extensions/pharos-imageis/trunk/perllib/plugins/PharosImagePlugin.pm	(revision 21342)
+++ /gs3-extensions/pharos-imageis/trunk/perllib/plugins/PharosImagePlugin.pm	(revision 21343)
@@ -38,9 +38,28 @@
 }
 
+my $index_on_list =
+    [ { 'name' => "original",
+        'desc' => "the original full sized file (will convert to jpg if necessary)" },
+      { 'name' => "screenview",
+        'desc' => "The screenview sized image (jpg screenview images will be created)" }, 
+      { 'name' => "thumbnail",
+        'desc' => "The thumbnail image (jpg thumbnails will be created)" } ];
+
+
 my $arguments = [
+		 { 'name' => "disable_pharos_imageis",
+		   'desc' => "Switch off the image similarity indexing",
+		   'type' => "flag",
+		   'reqd' => "no" },
+		 { 'name' => "pharos_imageis_index",
+		   'desc' => "Which size image files to index",
+		   'type' => "enum",
+		   'deft' => "thumbnail",
+		   'list' => $index_on_list,
+		   'reqd' => "no"}
 		 ];
 
 my $options = { 'name' => "PharosImagePlugin",
-		'desc' => "{PharosImagePlugin.desc}",
+		'desc' => "Image Plugin that also does Pharos Image Similarity Indexing",
 		'abstract' => "no",
 		'inherits' => "yes",
@@ -58,5 +77,42 @@
     my $self = new ImagePlugin($pluginlist, $inputargs, $hashArgOptLists);
 
+    if ($self->{'disable_pharos_imageis'}) {
+	# pharos disabled, don't care about args
+	return bless $self, $class;
+    }
+    
+    # we want imageconverter to store the paths to thumbnails etc so we can use them later.
+    $self->{'store_file_paths'} = 1;
+    # check args
+    if ($self->{'pharos_imageis_index'} eq "thumbnail") {
+	# thumbnails
+	if ($self->{'create_thumbnail'} eq "false") {
+	    print STDERR "Pharos Indexing set to index thumbnails, switching on -create_thumbnail\n";
+	    $self->{'create_thumbnail'} = "true";
+	}
+	if ($self->{'thumbnailtype'} !~ /^jpe?g$/i) {
+	    print STDERR "Pharos Indexing set to index thumbnails, setting thumbnailtype to jpg\n";
+	    $self->{'thumbnailtype'} = "jpg";
+	}
+    } elsif ($self->{'pharos_imageis_index'} eq "screenview") {
+	# screenview
+	if ($self->{'create_screenview'} eq "false") {
+	    print STDERR "Pharos Indexing set to index screenview, switching on -create_screenview\n";
+	    $self->{'create_screenview'} = "true";
+	}
+	if ($self->{'screenviewtype'} !~ /^jpe?g$/i) {
+	    print STDERR "Pharos Indexing set to index screenview, setting screenviewtype to jpg\n";
+	    $self->{'screenviewtype'} = "jpg";
+	}
+	
 
+    } else {
+	# originals
+	if (!$self->{'converttotype'} || $self->{'converttotype'}!~ /^jpe?g$/i) {
+	    print STDERR "Pharos Indexing set to index original images, setting  -converttotype to jpg\n";
+	    $self->{'converttotype'} = "jpg";
+	}
+	
+    }
     return bless $self, $class;
 
@@ -69,6 +125,9 @@
 
     $self->SUPER::init(@_);
-    $self->PharosImageIndexer::init();
+    $self->PharosImageIndexer::init() unless $self->{'disable_pharos_imageis'};
 
+    if (!$self->{'pharos_available'}) {
+	$self->{'disable_pharos_imageis'} = 1; # set this to one so we don't call the functions all the time and get lots of warnings
+    }
 }
 
@@ -78,5 +137,5 @@
     
     $self->SUPER::remove_all(@_);
-    $self->PharosImageIndexer::remove_all(@_);
+    $self->PharosImageIndexer::remove_all(@_) unless $self->{'disable_pharos_imageis'};
    
 }
@@ -87,5 +146,5 @@
     return undef if (!$self->can_process_this_file($file));
     
-    $self->PharosImageIndexer::remove_one(@_);
+    $self->PharosImageIndexer::remove_one(@_) unless $self->{'disable_pharos_imageis'};
     return $self->SUPER::remove_one(@_);
     
@@ -97,5 +156,21 @@
     # options??
     my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
-    $self->pharos_index_image(&util::filename_cat($base_dir, $file), $doc_obj);
+    return if $self->{'disable_pharos_imageis'};
+    if ($self->{'pharos_imageis_index'} eq "thumbnail" && -e $self->{'thumb_file'} ) {
+	print STDERR "indexing thumbnail $self->{'thumb_file'}\n";
+	$self->pharos_index_image($self->{'thumb_file'}, $doc_obj);
+    } elsif ($self->{'pharos_imageis_index'} eq "screenview" && -e $self->{'screen_file'}) {
+	print STDERR "indexing screenview $self->{'screen_file'}\n";
+	$self->pharos_index_image($self->{'screen_file'}, $doc_obj);
+    }
+    elsif (defined $self->{'orig_file'} && -e $self->{'orig_file'}) {
+	print STDERR "indexing converted original $self->{'orig_file'}\n";
+	$self->pharos_index_image($self->{'orig_file'}, $doc_obj);
+    }
+    else {
+	# fall back option, index the original
+	print STDERR "indexing original &util::filename_cat($base_dir, $file)\n";
+	$self->pharos_index_image(&util::filename_cat($base_dir, $file), $doc_obj);
+    }
 }
 
