########################################################################### # # PharosImageIndexer - helper plugin that does image conversion using ImageMagick # # A component of the Greenstone digital library software # from the New Zealand Digital Library Project at the # University of Waikato, New Zealand. # # Copyright (C) 2008 New Zealand Digital Library Project # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # ########################################################################### package PharosImageIndexer; use PrintInfo; use strict; no strict 'refs'; # allow filehandles to be variables and viceversa use gsprintf 'gsprintf'; BEGIN { @PharosImageIndexer::ISA = ('PrintInfo'); } my $arguments = [ { 'name' => "enable_pharos_imageis", 'desc' => "{PharosImageIndexer.enable_pharos_imageis}", 'type' => "flag", 'reqd' => "no" }, ]; my $options = { 'name' => "PharosImageIndexer", 'desc' => "{PharosImageIndexer.desc}", 'abstract' => "yes", 'inherits' => "yes", 'args' => $arguments }; sub new { my ($class) = shift (@_); my ($pluginlist,$inputargs,$hashArgOptLists) = @_; push(@$pluginlist, $class); push(@{$hashArgOptLists->{"ArgList"}},@{$arguments}); push(@{$hashArgOptLists->{"OptList"}},$options); my $self = new PrintInfo($pluginlist, $inputargs, $hashArgOptLists, 1); return bless $self, $class; } # needs to be called after BasePlugin init, so that outhandle is set up. sub init { my $self = shift(@_); if ($self->{'enable_pharos_imageis'}) { # Check that Pharos is installed and available on the path my $pharos_available = 1; ## change for windows! #my $result = `phraros-imageis-identify 2>&1`; #my $return_value = $?; #if ( ($ENV{'GSDLOS'} eq "windows" && $return_value == 256) || $return_value == -1) { # Linux and Windows return different values for "program not found" # $pharos_available = 0; #} $self->{'pharos_available'} = 1; #$pharos_available; if ($self->{'pharos_available'} == 0) { my $outhandle = $self->{'outhandle'}; &gsprintf($outhandle, "PharosImageIndexer: Pharos not installed\n"); } } } sub begin { } sub pharos_index_image { my $self = shift(@_); return unless $self->{'enable_pharos_imageis'}; # pass in the jpg thumbnail, and the doc obj my ($filename_full_path, $doc_obj) = @_; print STDERR "pharos indexing $filename_full_path\n"; my $collection = &util::get_current_collection_name(); my $id = $doc_obj->get_OID(); #my $result = `pharos-imageis-add.pl $collection $filename_full_path $id 2>&1`; my $result = `imageis-add-jpg-file.sh $collection $filename_full_path 2>&1`; my $return_value = $?; if ($return_value != 0) { my $outhandle = $self->{'outhandle'}; print $outhandle "Pharos Indexing failed for $filename_full_path, $id\n"; print $outhandle "$result\n"; } } 1;