source: gsdl/trunk/perllib/plugins/ImagePlugin.pm@ 17196

Last change on this file since 17196 was 17196, checked in by kjdon, 16 years ago

set cover_image to false as it makes no sense for images

  • Property svn:keywords set to Author Date Id Revision
File size: 3.8 KB
RevLine 
[1733]1###########################################################################
2#
[16820]3# ImagePlugin.pm -- for processing standalone images
[1733]4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 1999 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
[15872]26package ImagePlugin;
[1733]27
[15872]28use BasePlugin;
29use ImageConverter;
[1733]30
[10254]31use strict;
32no strict 'refs'; # allow filehandles to be variables and viceversa
[16856]33no strict 'subs';
[10254]34
[16856]35use gsprintf 'gsprintf';
36
[1733]37sub BEGIN {
[15872]38 @ImagePlugin::ISA = ('BasePlugin', 'ImageConverter');
[1733]39}
40
[4744]41my $arguments =
42 [ { 'name' => "process_exp",
[15872]43 'desc' => "{BasePlugin.process_exp}",
[6408]44 'type' => "regexp",
[4744]45 'deft' => &get_default_process_exp(),
46 'reqd' => "no" },
[15872]47 ];
[1758]48
[15872]49my $options = { 'name' => "ImagePlugin",
50 'desc' => "{ImagePlugin.desc}",
[6408]51 'abstract' => "no",
[3540]52 'inherits' => "yes",
53 'args' => $arguments };
54
55
[1744]56
[1733]57sub new {
[10218]58 my ($class) = shift (@_);
59 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
60 push(@$pluginlist, $class);
[4724]61
[15872]62 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
63 push(@{$hashArgOptLists->{"OptList"}},$options);
[2230]64
[15872]65 new ImageConverter($pluginlist, $inputargs, $hashArgOptLists);
66 my $self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists);
[1744]67
[1733]68 return bless $self, $class;
69}
70
[15872]71sub init {
72 my $self = shift (@_);
73 my ($verbosity, $outhandle, $failhandle) = @_;
74
75 $self->SUPER::init(@_);
76 $self->ImageConverter::init();
[17196]77 $self->{'cover_image'} = 0; # makes no sense for images
[15872]78}
79
[16847]80sub begin {
81 my $self = shift (@_);
82 my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
83
[16849]84 $self->SUPER::begin(@_);
[16847]85 $self->ImageConverter::begin();
86}
87
[1733]88sub get_default_process_exp {
89 my $self = shift (@_);
90
[1758]91 return q^(?i)(\.jpe?g|\.gif|\.png|\.bmp|\.xbm|\.tif?f)$^;
[1733]92}
93
[9067]94# this makes no sense for images
95sub block_cover_image
96{
97 my $self =shift (@_);
98 my ($filename) = @_;
[2230]99
[9067]100 return;
101}
[2230]102
[15872]103# do plugin specific processing of doc_obj
104sub process {
[1733]105 my $self = shift (@_);
[15872]106 # options??
107 my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
108
[16820]109
[2230]110 my $outhandle = $self->{'outhandle'};
[16383]111 my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
[16820]112
[16010]113 if ($self->{'image_conversion_available'} == 1) {
[16768]114 my $utf8_filename_no_path = $self->filepath_to_utf8($filename_no_path);
115 my $url_encoded_filename = &unicode::url_encode($utf8_filename_no_path);
116 $self->generate_images($filename_full_path, $url_encoded_filename, $doc_obj, $doc_obj->get_top_section()); # should we check the return value?
[15872]117 } else {
[16856]118 if ($gli) {
119 &gsprintf(STDERR, "<Warning p='ImagePlugin' r='{ImageConverter.noconversionavailable}: {ImageConverter.".$self->{'no_image_conversion_reason'}."}'>");
120 }
[2230]121 }
[15872]122 #we have no text - adds dummy text and NoText metadata
123 $self->add_dummy_text($doc_obj, $doc_obj->get_top_section());
[2230]124
[15872]125 return 1;
[4724]126
[3137]127}
[2230]128
[15872]129sub clean_up_after_doc_obj_processing {
[14951]130 my $self = shift(@_);
[1733]131
[15872]132 $self->ImageConverter::clean_up_temporary_files();
[1733]133}
134
1351;
[4724]136
137
138
139
140
141
142
143
144
145
146
Note: See TracBrowser for help on using the repository browser.