1 |
#!/usr/local/bin/perl -w |
2 |
|
3 |
use Image::Magick; |
4 |
use DBI; |
5 |
|
6 |
sub dump_gif { |
7 |
my ($text) = @_; |
8 |
my $file=$text; |
9 |
$file=~s/[^a-zA-Z]+/_/g; |
10 |
|
11 |
print "$text"; |
12 |
|
13 |
$image = Image::Magick->new; |
14 |
#$image->Set(size=>'125x15'); |
15 |
$image->Set(size=>'250x30'); |
16 |
$image->ReadImage('xc:#2a377e'); |
17 |
|
18 |
$image->Annotate(text=>$text, |
19 |
geometry=>'+14+4', |
20 |
font=>"\@/usr/local/ttfonts/arialbd.ttf", |
21 |
pointsize=>20, |
22 |
pen=>'white', |
23 |
align=>'left'); |
24 |
|
25 |
|
26 |
#$image->Resize(geometry=>'125x15', filter=>'Lanczos', blur=>1.8); |
27 |
#$image->GaussianBlur(radius=>1); |
28 |
$image->Scale(geometry=>'50%'); |
29 |
|
30 |
$image->Draw(stroke=>'#cccccc', primitive=>'line', points=>'0,14 118,14', linewidth=>1); |
31 |
$image->Draw(stroke=>'#cccccc', primitive=>'line', points=>'118,14 118,7', linewidth=>2); |
32 |
|
33 |
|
34 |
if (0) { |
35 |
$image->Annotate(text=> |
36 |
geometry=>'+7+2', |
37 |
font=>"\@/usr/local/ttfonts/arialbd.ttf", |
38 |
pointsize=>10, |
39 |
pen=>'white', |
40 |
align=>'left'); |
41 |
} |
42 |
|
43 |
print " -> "; |
44 |
|
45 |
$image->Write(filename=>"gif:m/$file.gif", |
46 |
colors=>256, |
47 |
interlace=>"none", |
48 |
compress=>'lzw'); |
49 |
|
50 |
print "$file.gif\n"; |
51 |
|
52 |
return "$file.gif"; |
53 |
|
54 |
} |
55 |
|
56 |
my $connect = "DBI:Pg:dbname=corp"; |
57 |
|
58 |
my $dbh = DBI->connect("$connect","","") || die $DBI::errstr; |
59 |
$sth = $dbh->prepare("select section,item,url from menu") || die $dbh->errstr(); |
60 |
$sth->execute() || die $sth->errstr(); |
61 |
|
62 |
while (@arr = $sth->fetchrow_array() ) { |
63 |
$dbh->do("update menu set file='".dump_gif($arr[1])."' where item='$arr[1]'"); |
64 |
} |