[l2h] In segmentation parts, how to create .png images or else BUT NOT .gif

Shigeharu TAKENO shige at iee.niit.ac.jp
Thu Apr 30 02:55:52 CEST 2020


shige 04/30 2020
----------------

I send a patch to reuse images at 2020-03-03:
| shige 03/03 2020
| ----------------
| 
| "Jacques B. Siboni" wrote:
| | -- When recompiling solely the slave, all of the 1000 master images are moved to
| | .old, and the new ones are inserted as imgxxx.gif
| 
| This may be a bug of latex2html-2018.3 or later. L2h of such 
| versions do not write image size info 'WIDTH="nnn" HEIGHT="nnn"'
| in the IMG tag for equations. However, because l2h uses the size
| info to decide to reuse images in process_undefined_environment(),
| it can't reuse images made at previous compilation.
| 
| To workaround the problem, to use latex2html-2018.2 or earlier, 
| or to apply the following patch:
| 
| ----- From here -----
| --- latex2html.pin.ORG  2019-12-29 21:03:41.052544000 +0900
| +++ latex2html.pin      2020-03-03 11:39:41.900813000 +0900
| @@ -3567,10 +3567,14 @@
|  #          }
|             # quotes will not be there with HTML 2.0
|             $size =~ s/\"//g if ($HTML_VERSION < 2.2);
| -           if ($size && /\s$size\s/) {
| +           # if ($size && /\s$size\s/) {
| +           # 2020-03-03 shige:
| +           if ($size && /;$size$/) {
|                 # Size is OK; recycle it!
|                 ++$global_page_num;
|                 $_ = $cached ;    # ...perhaps restoring the desired size.
| +               # 2020-03-03 shige:
| +               s/;$size$//;
|                 s/(${PREFIX}T?img)\d+\.($IMAGE_TYPE|html)/
|                         &rename_html($&,"$1$global_page_num.$2")/geo;
|             } else {
| @@ -3924,6 +3928,8 @@
|  sub make_images {
|      local($name, $contents, $raw_contents, $uucontents, $page_num,
|           $uucontents, %page_map, $img);
| +    # 2020-03-03 shige:
| +    local $imgsize;
|      # It is necessary to run LaTeX this early because we need the log file
|      # which contains information used to determine equation alignment
|      if ( $latex_body =~ /newpage/) {
| @@ -4021,7 +4027,9 @@
|         $contents = $latex_body{$name};
|         if ($page_num =~ /^\d+\#\d+$/) { # If it is a page number
|             do {                # Extract the page, convert and save it
| -               $img = &extract_image($page_num,$orig_name_map{$page_num});
| +               # $img = &extract_image($page_num,$orig_name_map{$page_num});
| +               # 2020-03-03 shige:
| +               ($img, $imgsize) = &extract_image($page_num,$orig_name_map{$page_num});
|                 if ($contents =~ /$htmlimage_rx/) {
|                     $uucontents = &special_encoding($env,$2,$contents);
|                 } elsif ($contents =~ /$htmlimage_pr_rx/) {
| @@ -4031,6 +4039,8 @@
|                 }
|                 if (($HTML_VERSION >=3.2)||!($contents=~/$order_sensitive_rx/)){
|                     $cached_env_img{$uucontents} = $img;
| +                   # 2020-03-03 shige:
| +                   if ($imgsize) { $cached_env_img{$uucontents} .= ";$imgsize"; }
|                 } else {
|                      # Blow it away so it is not saved for next time
|                     delete $cached_env_img{$uucontents};
| @@ -10271,7 +10281,9 @@
|             $result .= ">";
|  #      }
|      }
| -    join('',$anch1, $result, $anch2);
| +    # join('',$anch1, $result, $anch2);
| +    # 2020-03-03 shige:
| +    (join('',$anch1, $result, $anch2), $imagesize);
|  }
|  
|  # MRO: added PNG support
| ----- To here -----

I found that we have to modify styles/graphics-support.perl to 
include PNG image (not EPS) by \includegraphics together with 
above patch as followings:

----- From here -----
--- styles/graphics-support.perl.ORG	2020-04-30 09:43:32.871410000 +0900
+++ styles/graphics-support.perl	2020-04-30 09:42:17.350389000 +0900
@@ -342,8 +342,13 @@
       (L2hos->Copy($src,$dst) or # Would be nice to preserve timestamps, too.
        &write_warnings("\\includegraphics couldn't copy $src to tree: $!\n"))
 	unless (-f $dst) && (-M $dst < -M $src); 
-      join('',embed_image($dst,'web image',0,"Image $name", '','','','','',
-			  qq(WIDTH="$w" HEIGHT="$h")),$save); }
+      # join('',embed_image($dst,'web image',0,"Image $name", '','','','','',
+      #			  qq(WIDTH="$w" HEIGHT="$h")),$save); }
+      # 2020-04-28 shige: 2-45)
+      my ($img, $imgsize) = embed_image($dst,'web image',0,"Image $name", 
+					'','','','','',
+					qq(WIDTH="$w" HEIGHT="$h"));
+      join('',$img,$save); }
     # --------------------------------------------------
     # Complicated case: but if netpbm utilities are not available...
     elsif ($ALWAYS_USE_LATEX) {
@@ -439,8 +444,13 @@
         print "\ngraphics: $pipe\n" if ($VERBOSITY > 1);
 	system($pipe)==0 || 
 	  &write_warnings("\\includegraphics processing of $src failed! $!");
-	$img = embed_image($dst,'web image',0,"Image $name", '','','','','',
-			   qq(WIDTH="$w" HEIGHT="$h")); 
+	# $img = embed_image($dst,'web image',0,"Image $name", '','','','','',
+	# 		   qq(WIDTH="$w" HEIGHT="$h")); 
+	# 2020-04-28 shige: 2-45)
+	my $imgsize;
+	($img, $imgsize) = embed_image($dst,'web image',0,"Image $name", 
+				       '','','','','',
+				       qq(WIDTH="$w" HEIGHT="$h")); 
 	$cached_env_img{$cacheid}=$img; }
       join('',$img,$save);
 	} # end of 'pipe through netpbm utilities'
----- To here -----

+========================================================+
 Shigeharu TAKENO     NIigata Institute of Technology
                       kashiwazaki,Niigata 945-1195 JAPAN
 shige at iee.niit.ac.jp   TEL(&FAX): +81-257-22-8161
+========================================================+


More information about the latex2html mailing list.