[Tkabber-dev] r1867 - in trunk/tkabber-plugins: . latex

tkabber-svn at jabber.ru tkabber-svn at jabber.ru
Thu Jan 14 11:14:31 MSK 2010


Author: sergei
Date: 2010-01-14 11:14:31 +0300 (Thu, 14 Jan 2010)
New Revision: 1867

Modified:
   trunk/tkabber-plugins/ChangeLog
   trunk/tkabber-plugins/latex/latex.tcl
Log:
	* latex/latex.tcl: Use -output-directory latex option instead of
	  changing working directory. Use dvigif if available to produce an
	  image to insert into a chat window.


Modified: trunk/tkabber-plugins/ChangeLog
===================================================================
--- trunk/tkabber-plugins/ChangeLog	2010-01-10 22:00:38 UTC (rev 1866)
+++ trunk/tkabber-plugins/ChangeLog	2010-01-14 08:14:31 UTC (rev 1867)
@@ -1,3 +1,9 @@
+2010-01-14  Sergei Golovan <sgolovan at nes.ru>
+
+	* latex/latex.tcl: Use -output-directory latex option instead of
+	  changing working directory. Use dvigif if available to produce an
+	  image to insert into a chat window.
+
 2009-12-29  Sergei Golovan <sgolovan at nes.ru>
 
 	* floatinglog/floatinglog.tcl: Check if the floatinglog window exists

Modified: trunk/tkabber-plugins/latex/latex.tcl
===================================================================
--- trunk/tkabber-plugins/latex/latex.tcl	2010-01-10 22:00:38 UTC (rev 1866)
+++ trunk/tkabber-plugins/latex/latex.tcl	2010-01-14 08:14:31 UTC (rev 1867)
@@ -111,28 +111,39 @@
 	      \\end{document}"
     close $fd
 
-    set wd [pwd]
     if {[catch {
-	    cd $dirname
-	    exec latex -interaction=batchmode out.tex $null
-	    exec dvips -o [file join $dirname out.eps] \
-		       -E \
-		       [file join $dirname out.dvi] $null
-	    exec convert +adjoin \
-			 -antialias \
-			 -density ${res}x${res} \
-			 [file join $dirname out.eps] \
-			 [file join $dirname out.gif] $null
+	    exec latex -output-directory $dirname \
+		       -interaction=batchmode out.tex $null
+	    if {[catch {
+		exec dvigif -o [file join $dirname out.gif] \
+			    -D $res \
+			    -T tight \
+			    [file join $dirname out.dvi] $null
+		} msg1]} {
+		debugmsg plugins "dvigif error: $msg1, trying dvips&convert"
+		exec dvips -o [file join $dirname out.eps] \
+			   -E \
+			   [file join $dirname out.dvi] $null
+		exec convert +adjoin \
+			     -antialias \
+			     -density ${res}x${res} \
+			     [file join $dirname out.eps] \
+			     [file join $dirname out.gif] $null
+	    }
 	} msg]} {
-	cd $wd
 	file delete -force $dirname
 	return -code error $msg
     }
 
     image create photo $imgname -file [file join $dirname out.gif]
-    cd $wd
     file delete -force $dirname
 
+    # dvigif produces 1x1 image if the page is empty
+    if {[image width $imgname] == 1 && [image height $imgname] == 1} {
+	image delete $imgname
+	return -code error "Image produced by dvigif is empty"
+    }
+
     # If the page is empty, dvips doesn't crop it, so we
     # check image height and width. Letter paper dimensions are 8.5in x 11in
     if {abs([image width $imgname] - [expr $res * 8.5]) < 1 && \
@@ -141,7 +152,7 @@
 	# formula appears. Otherwise large images will be stored
 	# and waste space
 	image delete $imgname
-	return -code error "Image is empty"
+	return -code error "Image produced by dvips & convert is empty"
     }
 
     return $imgname



More information about the Tkabber-dev mailing list