[LON-CAPA-cvs] cvs: loncom /interface printout.pl

albertel lon-capa-cvs@mail.lon-capa.org
Mon, 24 Apr 2006 21:30:06 -0000


albertel		Mon Apr 24 17:30:06 2006 EDT

  Modified files:              
    /loncom/interface	printout.pl 
  Log:
  - some versions of image magick mishandle converting animated gifs,
  - later version of image magick have changed to file name that is generated as a result of the conversion process
  
  
Index: loncom/interface/printout.pl
diff -u loncom/interface/printout.pl:1.97 loncom/interface/printout.pl:1.98
--- loncom/interface/printout.pl:1.97	Wed Apr 19 22:24:08 2006
+++ loncom/interface/printout.pl	Mon Apr 24 17:30:06 2006
@@ -238,15 +238,36 @@
 	      $done_conversion{$not_eps}=1;
 	      # print "Converting $not_eps -> $eps_f"; # Debugging
 	      system("convert $not_eps $eps_f");
-              #check is eps exist in prtspool
-              if(not -e $eps_f) {
+              # check is eps exist in prtspool
+              if (not -e $eps_f) {
+		  # converting an animated gif creates either:
+                  # anim.gif.eps.0
+                  # or
+                  # anim.gif-0.eps
 		  for (my $i=0;$i<10000;$i++) {
 		      if (-e $eps_f.'.'.$i) {
-			  rename $eps_f.'.'.$i, $eps_f;
+			  rename($eps_f.'.'.$i, $eps_f);
 			  last;
 		      }
+		      my $anim_eps = $eps_f;
+		      $anim_eps =~ s/(\.[^.]*)\.eps$/$1-$i\.eps/i;
+		      if (-e $anim_eps) {
+			  rename($anim_eps, $eps_f);
+			  last;
+		      }
+		  }
+	      }
+	      # imagemagick 6.2.0-6.2.7 fails to properly handle
+              # convert anim.gif anim.gif.eps
+              # it creates anim.eps instead. 
+              if (not -e $eps_f) {
+		  my $eps_f2 = $eps_f;
+		  $eps_f2 =~ s/\.[^.]*\.eps$/\.eps/i;
+		  if(-e $eps_f2) {
+		      rename($eps_f2,$eps_f);
 		  }
-	      }  
+	      }
+
 	  }
       }
       if ($advanced_role) {