| 15 | 
 ############################################################################## | 
 ############################################################################## | 
| 16 | 
 # | 
 # | 
| 17 | 
 # $Log$ | 
 # $Log$ | 
| 18 | 
  | 
 # Revision 1.3  2005/07/15 13:29:25  cnh | 
| 19 | 
  | 
 # Tidying paths to make it work elsewhere - maybe? | 
| 20 | 
  | 
 # | 
| 21 | 
  | 
 # Revision 1.2  2005/07/15 13:20:56  cnh | 
| 22 | 
  | 
 # Slight change to the fix - plus relative path in .latex2html-init | 
| 23 | 
  | 
 # | 
| 24 | 
 # Revision 1.1  2005/07/15 13:07:23  cnh | 
 # Revision 1.1  2005/07/15 13:07:23  cnh | 
| 25 | 
 # More cunning tricks to get rid of black lines | 
 # More cunning tricks to get rid of black lines | 
| 26 | 
 #  pnmcrop is junk! | 
 #  pnmcrop is junk! | 
| 274 | 
 # Supported format(s) | 
 # Supported format(s) | 
| 275 | 
 my @IMAGE_TYPES = qw(png gif); | 
 my @IMAGE_TYPES = qw(png gif); | 
| 276 | 
 # Netpbm | 
 # Netpbm | 
| 277 | 
 my $PNMCROP = '/home/cnh/downloads/netpbm-10.19bin/bin/pnmcrop -verbose'; | 
 my $PNMCROP = '/usr/bin/pnmcrop -verbose '; | 
 | 
 # my $PNMCROP = '/bin/cat'; | 
  | 
| 278 | 
 my $PNMCROPOPT = ''; | 
 my $PNMCROPOPT = ''; | 
| 279 | 
 # $PNMCROPOPT = '-sides'; | 
 $PNMCROPOPT = '-sides'; | 
| 280 | 
 # $PNMCROPOPT = '-white'; | 
 # $PNMCROPOPT = '-white'; | 
| 281 | 
 $PNMCROPOPT = '-black'; | 
 # $PNMCROPOPT = '-black'; | 
| 282 | 
 my $PPMQUANT = '/home/cnh/downloads/netpbm-10.19bin/bin/ppmquant'; | 
 my $PPMQUANT = '/usr/bin/ppmquant'; | 
| 283 | 
 my $PNMFLIP = '/home/cnh/downloads/netpbm-10.19bin/bin/pnmflip'; | 
 my $PNMFLIP = '/usr/bin/pnmflip'; | 
| 284 | 
 my $PNMCAT = '/home/cnh/downloads/netpbm-10.19bin/bin/pnmcat'; | 
 my $PNMCAT = '/usr/bin/pnmcat'; | 
| 285 | 
 my $PNMFILE = '/home/cnh/downloads/netpbm-10.19bin/bin/pnmfile'; | 
 my $PNMFILE = '/usr/bin/pnmfile'; | 
| 286 | 
 my $PBMMAKE = '/home/cnh/downloads/netpbm-10.19bin/bin/pbmmake'; | 
 my $PBMMAKE = '/usr/bin/pbmmake'; | 
| 287 | 
 # GIF support | 
 # GIF support | 
| 288 | 
 my $PPMTOGIF = '/home/cnh/downloads/netpbm-10.19bin/bin/ppmtogif'; | 
 my $PPMTOGIF = '/usr/bin/ppmtogif'; | 
| 289 | 
 # PNG support | 
 # PNG support | 
| 290 | 
 my $PNMTOPNG = '/home/cnh/downloads/netpbm-10.19bin/bin/pnmtopng'; | 
 my $PNMTOPNG = '/usr/bin/pnmtopng'; | 
| 291 | 
 # Temporary diskspace | 
 # Temporary diskspace | 
| 292 | 
 my $def_tmp = '/tmp'; # Space for temporary files | 
 my $def_tmp = '/tmp'; # Space for temporary files | 
| 293 | 
  | 
  | 
| 300 | 
 my $PAGE_VMARGIN = 72;       # dvips margin: 1 inch = 72pt | 
 my $PAGE_VMARGIN = 72;       # dvips margin: 1 inch = 72pt | 
| 301 | 
  | 
  | 
| 302 | 
 # The color to be made transparent | 
 # The color to be made transparent | 
| 303 | 
 # my $trans_color = '#ffffff'; | 
 my $trans_color = '#ffffff'; | 
 | 
 my $trans_color = '#000000'; | 
  | 
| 304 | 
  | 
  | 
| 305 | 
 ############################################################################### | 
 ############################################################################### | 
| 306 | 
 # Default settings | 
 # Default settings | 
| 1114 | 
   $EXTRA_CROP =~ s/v/rl/gi; # crop vertically | 
   $EXTRA_CROP =~ s/v/rl/gi; # crop vertically | 
| 1115 | 
   while ($EXTRA_CROP =~ /([atblrs])/gi) { | 
   while ($EXTRA_CROP =~ /([atblrs])/gi) { | 
| 1116 | 
     my $edge = $1; | 
     my $edge = $1; | 
| 1117 | 
     my $croparg = ' '; | 
     my $croparg = ''; | 
| 1118 | 
     if($edge =~ /b/i) { | 
     if($edge =~ /b/i) { | 
| 1119 | 
       $croparg = "-bot $PNMCROPOPT "; | 
       $croparg = "-bot $PNMCROPOPT "; | 
| 1120 | 
     } elsif($edge =~ /[tlr]/i) { | 
     } elsif($edge =~ /[tlr]/i) { | 
| 1123 | 
       #RRM: shave at most 1-2 rows of white from the bottom | 
       #RRM: shave at most 1-2 rows of white from the bottom | 
| 1124 | 
       if($cmd) { | 
       if($cmd) { | 
| 1125 | 
         # Terminate command pipe | 
         # Terminate command pipe | 
| 1126 | 
         $cmd .= "| pnmcrop -white -bot -verbose | pamcut -bottom 200 -pad | pnmcrop -black -bot -verbose"; | 
         ### CNH trick to get rid of black lines at bottom of some equations | 
| 1127 | 
  | 
         $cmd .= "| pnmcrop -white -bot -verbose | pnmcrop -black -bot -verbose | pnmcrop -white -bot -verbose | pnmcrop -black -bot -verbose"; | 
| 1128 | 
         &do_cmd($in,$tmp,$cmd) || return 0; # failure | 
         &do_cmd($in,$tmp,$cmd) || return 0; # failure | 
| 1129 | 
         $cmd = ''; | 
         $cmd = ''; | 
| 1130 | 
       } | 
       } | 
| 1131 | 
       my ($type,$width,$height) = get_image_geometry($in); | 
       my ($type,$width,$height) = get_image_geometry($in); | 
 | 
       #CNH add begin | 
  | 
 | 
       ###CNH next | 
  | 
 | 
       #CNH add end | 
  | 
| 1132 | 
       next unless($type); # skip if no geometry | 
       next unless($type); # skip if no geometry | 
| 1133 | 
       if(&do_cmd_norename("$PNMCROP $PNMCROPOPT -bot < $in",$tmp)) { | 
       if(&do_cmd_norename("$PNMCROP $PNMCROPOPT -bot < $in",$tmp)) { | 
| 1134 | 
         my ($type,$width,$height2) = get_image_geometry($tmp); | 
         my ($type,$width,$height2) = get_image_geometry($tmp); | 
| 1135 | 
         if($type && ($height - $height2) < 30 ) { | 
         if($type && ($height - $height2) < 3 ) { | 
| 1136 | 
           # command succeeded and shaved less than 3 rows | 
           # command succeeded and shaved less than 3 rows | 
| 1137 | 
           if($opt{debug}&&(-f $tmp)) { | 
           if($opt{debug}&&(-f $tmp)) { | 
| 1138 | 
             L2hos->Copy($tmp,$in); | 
             L2hos->Copy($tmp,$in); |