File:
[LON-CAPA] /
loncom /
build /
help_graphics_converter.pl
Revision
1.5:
download - view:
text,
annotated -
select for diffs
Mon Jan 2 11:37:02 2012 UTC (12 years, 7 months ago) by
foxr
Branches:
MAIN
CVS tags:
version_2_12_X,
version_2_11_X,
version_2_11_5_msu,
version_2_11_5,
version_2_11_4_uiuc,
version_2_11_4_msu,
version_2_11_4,
version_2_11_3_uiuc,
version_2_11_3_msu,
version_2_11_3,
version_2_11_2_uiuc,
version_2_11_2_msu,
version_2_11_2_educog,
version_2_11_2,
version_2_11_1,
version_2_11_0_RC3,
version_2_11_0_RC2,
version_2_11_0_RC1,
version_2_11_0,
HEAD,
BZ4492-merge,
BZ4492-feature_horizontal_radioresponse,
BZ4492-feature_Support_horizontal_radioresponse,
BZ4492-Support_horizontal_radioresponse
BZ 6534 - Make the converter aware of relative mtimes as well as
just the non-empty existence of the destination file.
1: # The LearningOnline Network
2: # help_graphics_converter - converts help .png into .gif and .eps
3: #
4: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
5: #
6: # LON-CAPA is free software; you can redistribute it and/or modify
7: # it under the terms of the GNU General Public License as published by
8: # the Free Software Foundation; either version 2 of the License, or
9: # (at your option) any later version.
10: #
11: # LON-CAPA is distributed in the hope that it will be useful,
12: # but WITHOUT ANY WARRANTY; without even the implied warranty of
13: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: # GNU General Public License for more details.
15: #
16: # You should have received a copy of the GNU General Public License
17: # along with LON-CAPA; if not, write to the Free Software
18: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: #
20: # /home/httpd/html/adm/gpl.txt
21: #
22: # http://www.lon-capa.org/
23: #
24: # YEAR=2002
25: # 7/4, Jeremy Bowers
26: #
27: ###
28:
29: use strict;
30:
31: ##
32: # Sub to determine the relative modification dates of files:
33: #
34: # @param file1 - First file
35: # @param file2 - Seond file
36: #
37: # @return - 0 if file 1's mtime is <= file2's 1 otherwise.
38: sub newer {
39: my ($file1, $file2) = @_;
40:
41: # IF file2 does not exist, return false to force the build:
42:
43: if (not (-s $file2)) {
44: return 0;
45: }
46:
47: # Check modification times if file2 exists:
48:
49: my $m1 = (stat($file1))[9];
50: my $m2 = (stat($file2))[9];
51:
52: return $m2 > $m1;
53: }
54:
55: my $dirprefix = "../html/adm/help/";
56:
57: # Check that the png directory exists
58: if (not (-d $dirprefix . "png/"))
59: { die "Can't convert help graphics because the png directory is not ".
60: "installed."; }
61:
62: mkdir $dirprefix . "gif/", 0755;
63: mkdir $dirprefix . "eps/", 0755;
64:
65: my $convert = `which convert`;
66: if ($convert eq '')
67: {
68: open LOG, ">> WARNINGS";
69: print LOG "**** ERROR **** ImageMagick is not installed. You must install ImageMagick to use LON-CAPA. Please see your installation instructions.\n";
70: print "**** ERROR **** ImageMagick is not installed. You must install ImageMagick to use LON-CAPA. Please see your installation instructions.\n";
71: exit;
72: }
73:
74: foreach my $file (glob($dirprefix . "png/*.png"))
75: {
76: my $filename = substr($file, rindex($file, "/") + 1);
77: my $gifdest = $dirprefix . "gif/" . substr($filename, 0, -4) . ".gif";
78: my $epsdest = $dirprefix . "eps/" . substr($filename, 0, -4) . ".eps";
79:
80:
81: print "Converting $filename... gif";
82: system ("convert $file $gifdest\n") if (not &newer($file, $gifdest));
83: print " eps";
84: system ("convert $file $epsdest\n") if (not &newer($file, $epsdest));
85: print " done.\n";
86: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>