File:  [LON-CAPA] / loncom / build / help_graphics_converter.pl
Revision 1.4: download - view: text, annotated - select for diffs
Mon Aug 19 21:40:55 2002 UTC (21 years, 8 months ago) by bowersj2
Branches: MAIN
CVS tags: version_2_9_X, version_2_9_99_0, version_2_9_1, version_2_9_0, version_2_8_X, version_2_8_99_1, version_2_8_99_0, version_2_8_2, version_2_8_1, version_2_8_0, version_2_7_X, version_2_7_99_1, version_2_7_99_0, version_2_7_1, version_2_7_0, version_2_6_X, version_2_6_99_1, version_2_6_99_0, version_2_6_3, version_2_6_2, version_2_6_1, version_2_6_0, version_2_5_X, version_2_5_99_1, version_2_5_99_0, version_2_5_2, version_2_5_1, version_2_5_0, version_2_4_X, version_2_4_99_0, version_2_4_2, version_2_4_1, version_2_4_0, version_2_3_X, version_2_3_99_0, version_2_3_2, version_2_3_1, version_2_3_0, version_2_2_X, version_2_2_99_1, version_2_2_99_0, version_2_2_2, version_2_2_1, version_2_2_0, version_2_1_X, version_2_1_99_3, version_2_1_99_2, version_2_1_99_1, version_2_1_99_0, version_2_1_3, version_2_1_2, version_2_1_1, version_2_1_0, version_2_10_X, version_2_10_1, version_2_10_0_RC2, version_2_10_0_RC1, version_2_10_0, version_2_0_X, version_2_0_99_1, version_2_0_2, version_2_0_1, version_2_0_0, version_1_99_3, version_1_99_2, version_1_99_1_tmcc, version_1_99_1, version_1_99_0_tmcc, version_1_99_0, version_1_3_X, version_1_3_3, version_1_3_2, version_1_3_1, version_1_3_0, version_1_2_X, version_1_2_99_1, version_1_2_99_0, version_1_2_1, version_1_2_0, version_1_1_X, version_1_1_99_5, version_1_1_99_4, version_1_1_99_3, version_1_1_99_2, version_1_1_99_1, version_1_1_99_0, version_1_1_3, version_1_1_2, version_1_1_1, version_1_1_0, version_1_0_99_3, version_1_0_99_2, version_1_0_99_1, version_1_0_99, version_1_0_3, version_1_0_2, version_1_0_1, version_1_0_0, version_0_99_5, version_0_99_4, version_0_99_3, version_0_99_2, version_0_99_1, version_0_99_0, version_0_6_2, version_0_6, loncapaMITrelate_1, language_hyphenation_merge, language_hyphenation, conference_2003, bz6209-base, bz6209, bz5969, bz5610, bz2851, PRINT_INCOMPLETE_base, PRINT_INCOMPLETE, HEAD, GCI_3, GCI_2, GCI_1, BZ5971-printing-apage, BZ5434-fox
Detects absense of ImageMagick during graphics conversion and issues an
**** ERROR **** if ImageMagick is not installed.

# The LearningOnline Network
# help_graphics_converter - converts help .png into .gif and .eps
#
# This file is part of the LearningOnline Network with CAPA (LON-CAPA).
#
# LON-CAPA is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# LON-CAPA is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LON-CAPA; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
# /home/httpd/html/adm/gpl.txt
#
# http://www.lon-capa.org/
#
# YEAR=2002
# 7/4, Jeremy Bowers
#
###

use strict;

my $dirprefix = "../html/adm/help/";

# Check that the png directory exists
if (not (-d $dirprefix . "png/"))
{ die "Can't convert help graphics because the png directory is not ".
      "installed."; }

mkdir $dirprefix . "gif/", 0755;
mkdir $dirprefix . "eps/", 0755;

my $convert = `which convert`;
if ($convert eq '')
{
    open LOG, ">> WARNINGS";
    print LOG "**** ERROR **** ImageMagick is not installed. You must install ImageMagick to use LON-CAPA. Please see your installation instructions.\n";
    print "**** ERROR **** ImageMagick is not installed. You must install ImageMagick to use LON-CAPA. Please see your installation instructions.\n";
    exit;
}

foreach my $file (glob($dirprefix . "png/*.png"))
{
    my $filename = substr($file, rindex($file, "/") + 1);
    my $gifdest = $dirprefix . "gif/" . substr($filename, 0, -4) . ".gif";
    my $epsdest = $dirprefix . "eps/" . substr($filename, 0, -4) . ".eps";
    
    
    print "Converting $filename... gif";
    system ("convert $file $gifdest\n") if (not (-s $gifdest));
    print " eps";
    system ("convert $file $epsdest\n") if (not (-s $epsdest));
    print " done.\n";
}

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>