########################################################################### # # ImagePlugin.pm -- for processing standalone images # A component of the Greenstone digital library software # from the New Zealand Digital Library Project at the # University of Waikato, New Zealand. # # Copyright (C) 1999 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 ImagePlugin; use BasePlugin; use ImageConverter; use strict; no strict 'refs'; # allow filehandles to be variables and viceversa no strict 'subs'; use gsprintf 'gsprintf'; sub BEGIN { @ImagePlugin::ISA = ('BasePlugin', 'ImageConverter'); } my $arguments = [ { 'name' => "process_exp", 'desc' => "{BasePlugin.process_exp}", 'type' => "regexp", 'deft' => &get_default_process_exp(), 'reqd' => "no" }, ]; my $options = { 'name' => "ImagePlugin", 'desc' => "{ImagePlugin.desc}", 'abstract' => "no", 'inherits' => "yes", 'args' => $arguments }; sub new { my ($class) = shift (@_); my ($pluginlist,$inputargs,$hashArgOptLists) = @_; push(@$pluginlist, $class); push(@{$hashArgOptLists->{"ArgList"}},@{$arguments}); push(@{$hashArgOptLists->{"OptList"}},$options); new ImageConverter($pluginlist, $inputargs, $hashArgOptLists); my $self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists); return bless $self, $class; } sub init { my $self = shift (@_); my ($verbosity, $outhandle, $failhandle) = @_; $self->SUPER::init(@_); $self->ImageConverter::init(); $self->{'cover_image'} = 0; # makes no sense for images } sub begin { my $self = shift (@_); my ($pluginfo, $base_dir, $processor, $maxdocs) = @_; $self->SUPER::begin(@_); $self->ImageConverter::begin(); } sub get_default_process_exp { my $self = shift (@_); return q^(?i)(\.jpe?g|\.gif|\.png|\.bmp|\.xbm|\.tif?f)$^; } # this makes no sense for images sub block_cover_image { my $self =shift (@_); my ($filename) = @_; return; } # do plugin specific processing of doc_obj sub process { my $self = shift (@_); # options?? my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_; my $outhandle = $self->{'outhandle'}; my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file); if ($self->{'image_conversion_available'} == 1) { my $utf8_filename_no_path = $self->filepath_to_utf8($filename_no_path); my $url_encoded_filename = &unicode::url_encode($utf8_filename_no_path); $self->generate_images($filename_full_path, $url_encoded_filename, $doc_obj, $doc_obj->get_top_section()); # should we check the return value? } else { if ($gli) { &gsprintf(STDERR, ""); } } #we have no text - adds dummy text and NoText metadata $self->add_dummy_text($doc_obj, $doc_obj->get_top_section()); return 1; } sub clean_up_after_doc_obj_processing { my $self = shift(@_); $self->ImageConverter::clean_up_temporary_files(); } 1;