jablonka.czprosek.czf

hotsanic

Subversion Repositories:
[/] [branches/] [HotSaNIC-0.5.0-jablonecka/] [convert.pl] - Blame information for rev 18

 

Line No. Rev Author Line
11simandl#!/usr/bin/env perl
2use strict;
3use warnings;
4use diagnostics;
5 
6use File::Find;
7use lib "./lib";
8use HotSaNICparser;
9 
10my $module=$ARGV[0] || "";
11$module=~ s/modules\///;
12$module="/".$module;
13if ($module eq "/") {$module="";}
14 
15my %CONFIG = HotSaNICparser::get_config(".");
16my $thumbsize = $CONFIG{THUMBSIZE} || "20%";
17my $method = $CONFIG{CONVERTMETHOD} || "HTML";
18 
19if ($module ne "") {print "converting ",$CONFIG{WEBDIR},$module,"\n";}
20 
21# exit if method is HTML or unknown
22if (index("ImgMgck I::M",$method) == -1) { exit 0; }
23 
24# check if the ImageMagick perl-module is installed
25if ($method eq 'I::M') {
26 eval { require Image::Magick; };
27 if ($@) {
28 print "$0: Perlmodule Image::Magick not installed\n";
29 $method = "ImgMgck";
30 } else {
31 require Image::Magick;
32 print "Using Image::Magick perl-module\n";
33 }
34}
35 
36# build array with all weekly diagram files in the web-dir
37#
38require File::Find;
39my @files;
40$File::Find::name=""; # suppress stupid warning...
41File::Find::find( {wanted => sub { /^.*-week\..*\z/s && push @files, $File::Find::name; } }, $CONFIG{WEBDIR}.$module);
42 
43my $cmd;
44 
45foreach my $file ( @files ) {
46 my $thumb=$file;
47 $thumb=~ s/^(.+)\/(.+)-week\.(.+)$/$1\/thumb-$2\.$3/;
48# print "$file -> $thumb\n";
49 print "resizing $file\n";
50 
51 if ($method eq "I::M") {
52 my $image = new Image::Magick;
53 $image->Read($file);
54 $image->Scale(geometry => "$thumbsize");
55 $image->Write($thumb);
56 }
57 else {
58 if ( -x $CONFIG{CONVERTPATH} ) {
59 $cmd = "$CONFIG{CONVERTPATH} -geometry $thumbsize $file $thumb";
60 # print "$cmd\n";
61 system($cmd) == 0
62 or warn "$0: could not convert $file to $thumb: $!";
63 }
64 }
65 }
66 
67exit;
68 

Powered by WebSVN 2.2.1