Ignore:
Timestamp:
2011-09-15T16:31:11+12:00 (13 years ago)
Author:
ak19
Message:

Added gs-magick.pl script which will set the environment for ImageMagick (including LD_LIBRARY_PATH) before launching the requested ImageMagick command and arguments. By setting the Imagemagick environment from this script we ensure that the modified env variables don't create conflicts with libraries needed for normal linux execution. All the Greenstone files in the *binary* that made direct calls to imagemagick now go through this script. The affected files are perl files in bin/script and perllib and Gatherer.java of GLI. (wvware has files that test for imagemagick during compilation stage, which is independent of our changs which are only for users running imagemagick from a GS binary.) The final problems were related to how different perl files made use of the return values and the output of running their imagemagick command: they would query the 127 and/or and/or run the command with backtick operators to get the output printed to STDOUT. By inserting an intermediate gs-magick.pl file, needed to ensure that the exit code stored in 127 would at least be passed on correctly, as is necessary when testing the exit code against non-zero values or greater/less than zero (instead of comparing them with equals/not equal to 0). To get the correct exit code as emitted by imagemagick, calling code needs to shift bits in 127 and converting it to a signed value.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/gsConvert.pl

    r24513 r24600  
    824824    # Check that ImageMagick is installed and available on the path (except for Windows 95/98)
    825825    if (!($ENV{'GSDLOS'} eq "windows" && !Win32::IsWinNT())) {
    826     my $result = `identify 2>&1`;
    827     if ($? == -1 || $? == 256) {  # Linux and Windows return different values for "program not found"
     826    my $imagick_cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl";
     827    my $result = `$imagick_cmd identify 2>&1`;
     828
     829    # Linux and Windows return different values for "program not found".
     830    # Linux returns -1 and Windows 256 for "program not found". But once they're
     831    # converted to signed values, it will be -1 for Linux and 1 for Windows.
     832    # Whenever we test for return values other than 0, shift by 8 and perform
     833    # unsigned to signed status conversion on $? to get expected range of return vals
     834    # Although gs-magick.pl already shifts its $? by 8, converts it to a signed value
     835    # and then exits on that, by the time we get here, we need to do it again
     836    my $status = $?;
     837    $status >>= 8;
     838    $status = (($status & 0x80) ? -(0x100 - ($status & 0xFF)) : $status);   
     839    if ($status == -1 || $status == 1) { #if ($status == -1 || $status == 256) {
    828840        #ImageMagick is not installed, thus the convert utility is not available.
    829841        print STDERR "*** ImageMagick is not installed, the convert utility is not available. Unable to convert PDF/PS to images\n";
Note: See TracChangeset for help on using the changeset viewer.