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

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

changed the imagemagick check before calling generate images

  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1###########################################################################
2#
3# ImagePlugin.pm -- simple text plugin
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
33
34sub BEGIN {
35 @ImagePlugin::ISA = ('BasePlugin', 'ImageConverter');
36}
37
38my $arguments =
39 [ { 'name' => "process_exp",
40 'desc' => "{BasePlugin.process_exp}",
41 'type' => "regexp",
42 'deft' => &get_default_process_exp(),
43 'reqd' => "no" },
44 ];
45
46my $options = { 'name' => "ImagePlugin",
47 'desc' => "{ImagePlugin.desc}",
48 'abstract' => "no",
49 'inherits' => "yes",
50 'args' => $arguments };
51
52
53
54sub new {
55 my ($class) = shift (@_);
56 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
57 push(@$pluginlist, $class);
58
59 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
60 push(@{$hashArgOptLists->{"OptList"}},$options);
61
62 new ImageConverter($pluginlist, $inputargs, $hashArgOptLists);
63 my $self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists);
64
65 return bless $self, $class;
66}
67
68sub init {
69 my $self = shift (@_);
70 my ($verbosity, $outhandle, $failhandle) = @_;
71
72 $self->SUPER::init(@_);
73 $self->ImageConverter::init();
74}
75
76sub get_default_process_exp {
77 my $self = shift (@_);
78
79 return q^(?i)(\.jpe?g|\.gif|\.png|\.bmp|\.xbm|\.tif?f)$^;
80}
81
82# this makes no sense for images
83sub block_cover_image
84{
85 my $self =shift (@_);
86 my ($filename) = @_;
87
88 return;
89}
90
91# do plugin specific processing of doc_obj
92sub process {
93 my $self = shift (@_);
94 # options??
95 my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
96
97 my $outhandle = $self->{'outhandle'};
98 my ($filename_full_path, $filename_no_path) = $self->get_full_filenames($base_dir, $file);
99 if ($self->{'image_conversion_available'} == 1) {
100 $self->generate_images($filename_full_path, $filename_no_path, $doc_obj, $doc_obj->get_top_section()); # should we check the return value?
101 } else {
102 # do some basic stuff
103 # associate the image, fileformat, mimetype, srclink, srcicon
104 # do this if image magick not installed. but also if generate hasn't worked?? what about images too small?
105 }
106 #we have no text - adds dummy text and NoText metadata
107 $self->add_dummy_text($doc_obj, $doc_obj->get_top_section());
108
109 return 1;
110
111}
112
113sub clean_up_after_doc_obj_processing {
114 my $self = shift(@_);
115
116 $self->ImageConverter::clean_up_temporary_files();
117}
118
1191;
120
121
122
123
124
125
126
127
128
129
130
Note: See TracBrowser for help on using the repository browser.