Changeset 1758
- Timestamp:
- 2000-12-07T11:48:22+13:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/plugins/ImagePlug.pm
r1744 r1758 33 33 34 34 use strict; 35 35 36 sub print_general_usage { 36 37 my ($plugin_name) = @_; … … 41 42 print STDERR " -thumbnailsize n Make thumbnails of size nxn\n"; 42 43 print STDERR " -convertto s Convert main inage to (gif|png|jpg)\n"; 44 print STDERR " -minimumsize n Ignore images smaller than n bytes\n"; 43 45 print STDERR "\n"; 44 46 } … … 55 57 q^converttotype/.*/^, \$self->{'converttotype'}, 56 58 q^thumbnailsize/[0-9]*/100^, \$self->{'thumbnailsize'}, 59 q^minimumsize/[0-9]*/100^, \$self->{'minimumsize'}, 57 60 "allow_extra_options")) { 58 61 … … 69 72 my $self = shift (@_); 70 73 71 return q^(?i)(\.jpe?g|\.gif|\.png|\.bmp|\. tiff?)$^;74 return q^(?i)(\.jpe?g|\.gif|\.png|\.bmp|\.xbm|\.tif?f)$^; 72 75 } 73 76 … … 82 85 return ""; 83 86 } 84 if ($filename =~ m/thumbnail/) { 87 # if ($filename =~ m/thumbnail/) { 88 # return ""; 89 # } 90 # if ($filename =~ m/converted/) { 91 # return ""; 92 # } 93 if ($filename =~ m/ /) { 94 print STDERR "IamgePlug: \"$filename\" contains a space. choking.\n"; 85 95 return ""; 86 96 } 87 if ($filename =~ m/converted/) { 88 return ""; 89 } 90 if ($filename =~ m/\..*\./) { 91 return ""; 92 } 93 97 98 my $minimumsize = $self->{'minimumsize'}; 94 99 my $thumbSize = $self->{'thumbnailsize'}; 95 100 if ($thumbSize eq "") { $thumbSize = 100; }; … … 101 106 102 107 my $type = "unknown"; 103 108 109 if (defined $minimumsize && (-s $filename < $minimumsize)) { 110 print STDERR "ImagePlug: \"$filename\" too small, skipping\n" 111 if $self->{'verbosity'} > 1; 112 } 104 113 #see if we need to convert ... 105 if ($converttotype ne "" && $filename =~ m/$converttotype$/) 106 { 114 if ($converttotype ne "" && $filename =~ m/$converttotype$/) { 107 115 $originalfilename = $filename; 108 116 $filename = &util::get_tmp_filename(); … … 137 145 if $self->{'verbosity'} > 3; 138 146 139 if ($result =~ m/ =>.* ([0-9]+)x([0-9]+)=>([0-9]+)x([0-9]+)/m) {147 if ($result =~ m/([0-9]+)x([0-9]+)=>([0-9]+)x([0-9]+)/) { 140 148 $doc_obj->add_metadata ($section, "ImageHeight", $1); 141 149 $doc_obj->add_metadata ($section, "ImageWidth", $2); … … 167 175 $type = "bmp"; 168 176 } 169 177 if ($result =~ m/^[^\n]*XBM?F/i) { 178 $type = "xbm"; 179 } 180 170 181 #if there's a leading directory name, eat it... 171 182 $file =~ s/^[^\/\\]*[\/\\]//; … … 209 220 210 221 my $filename = &util::filename_cat($base_dir, $file); 211 print STDERR "ImagePlug: called on \"$filename\"\n"212 if $self->{'verbosity'} > 1;213 222 return 0 if $self->{'block_exp'} ne "" && $filename =~ /$self->{'block_exp'}/; 214 223 if ($filename !~ /$self->{'process_exp'}/ || !-f $filename) { 215 224 return undef; 216 225 } 217 my $plugin_name = ref ($self); 226 print STDERR "ImagePlug: called on \"$filename\"\n" 227 if $self->{'verbosity'} > 1; 228 218 229 $file =~ s/^[\/\\]+//; # $file often begins with / so we'll tidy it up 219 230 … … 222 233 223 234 #run convert to get the thumbnail and extract size and type info 224 my $ thumbnailfile= run_convert($self, $filename, $file, $doc_obj);225 226 if (!defined $ thumbnailfile)235 my $result = run_convert($self, $filename, $file, $doc_obj); 236 237 if (!defined $result) 227 238 { 228 239 print "ImagePlug: couldn't process \"$filename\"\n"; … … 261 272 } 262 273 263 return 1; # processed the file274 return $result; # processed the file 264 275 } 265 276
Note:
See TracChangeset
for help on using the changeset viewer.