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

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

in gli mode, print a warning about can't process images

  • Property svn:keywords set to Author Date Id Revision
File size: 3.7 KB
Line 
1###########################################################################
2#
3# ImagePlugin.pm -- for processing standalone images
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
26package ImagePlugin;
27
28use BasePlugin;
29use ImageConverter;
30
31use strict;
32no strict 'refs'; # allow filehandles to be variables and viceversa
33no strict 'subs';
34
35use gsprintf 'gsprintf';
36
37sub BEGIN {
38 @ImagePlugin::ISA = ('BasePlugin', 'ImageConverter');
39}
40
41my $arguments =
42 [ { 'name' => "process_exp",
43 'desc' => "{BasePlugin.process_exp}",
44 'type' => "regexp",
45 'deft' => &get_default_process_exp(),
46 'reqd' => "no" },
47 ];
48
49my $options = { 'name' => "ImagePlugin",
50 'desc' => "{ImagePlugin.desc}",
51 'abstract' => "no",
52 'inherits' => "yes",
53 'args' => $arguments };
54
55
56
57sub new {
58 my ($class) = shift (@_);
59 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
60 push(@$pluginlist, $class);
61
62 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
63 push(@{$hashArgOptLists->{"OptList"}},$options);
64
65 new ImageConverter($pluginlist, $inputargs, $hashArgOptLists);
66 my $self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists);
67
68 return bless $self, $class;
69}
70
71sub init {
72 my $self = shift (@_);
73 my ($verbosity, $outhandle, $failhandle) = @_;
74
75 $self->SUPER::init(@_);
76 $self->ImageConverter::init();
77}
78
79sub begin {
80 my $self = shift (@_);
81 my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
82
83 $self->SUPER::begin(@_);
84 $self->ImageConverter::begin();
85}
86
87sub get_default_process_exp {
88 my $self = shift (@_);
89
90 return q^(?i)(\.jpe?g|\.gif|\.png|\.bmp|\.xbm|\.tif?f)$^;
91}
92
93# this makes no sense for images
94sub block_cover_image
95{
96 my $self =shift (@_);
97 my ($filename) = @_;
98
99 return;
100}
101
102# do plugin specific processing of doc_obj
103sub process {
104 my $self = shift (@_);
105 # options??
106 my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
107
108
109 my $outhandle = $self->{'outhandle'};
110 my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
111
112 if ($self->{'image_conversion_available'} == 1) {
113 my $utf8_filename_no_path = $self->filepath_to_utf8($filename_no_path);
114 my $url_encoded_filename = &unicode::url_encode($utf8_filename_no_path);
115 $self->generate_images($filename_full_path, $url_encoded_filename, $doc_obj, $doc_obj->get_top_section()); # should we check the return value?
116 } else {
117 if ($gli) {
118 &gsprintf(STDERR, "<Warning p='ImagePlugin' r='{ImageConverter.noconversionavailable}: {ImageConverter.".$self->{'no_image_conversion_reason'}."}'>");
119 }
120 }
121 #we have no text - adds dummy text and NoText metadata
122 $self->add_dummy_text($doc_obj, $doc_obj->get_top_section());
123
124 return 1;
125
126}
127
128sub clean_up_after_doc_obj_processing {
129 my $self = shift(@_);
130
131 $self->ImageConverter::clean_up_temporary_files();
132}
133
1341;
135
136
137
138
139
140
141
142
143
144
145
Note: See TracBrowser for help on using the repository browser.