r59593 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59592‎ | r59593 | r59594 >
Date:18:42, 30 November 2009
Author:freakolowsky
Status:resolved (Comments)
Tags:
Comment:
* Added 5th parameter to texvc call (can be null and defaults to rgb '1.0 1.0 1.0').
This parameter controls texvc background color. Can be set to output transparent background
* Added $wgTexvcBackgroundColor parameter to DefaultSettings with value 'rgb 1.0 1.0 1.0'
* Changed Math.php to call texvc with new parameter
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/DefaultSettings.php (modified) (history)
  • /trunk/phase3/includes/Math.php (modified) (history)
  • /trunk/phase3/math/README (modified) (history)
  • /trunk/phase3/math/render.ml (modified) (history)
  • /trunk/phase3/math/texvc.ml (modified) (history)

Diff [purge]

Index: trunk/phase3/math/render.ml
@@ -5,11 +5,11 @@
66 (* Putting -bg Transparent in dvipng's arguments will give full-alpha transparency *)
77 (* Note that IE have problems with such PNGs and need an additional javascript snippet *)
88 (* Putting -bg transparent in dvipng's arguments will give binary transparency *)
9 -let cmd_dvipng tmpprefix finalpath = "dvipng -gamma 1.5 -D 120 -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null"
 9+let cmd_dvipng tmpprefix finalpath backcolor = "dvipng -bg \'" ^ backcolor ^ "\' -gamma 1.5 -D 120 -T tight --strict " ^ tmpprefix ^ ".dvi -o " ^ finalpath ^ " >/dev/null 2>/dev/null"
1010
1111 exception ExternalCommandFailure of string
1212
13 -let render tmppath finalpath outtex md5 =
 13+let render tmppath finalpath outtex md5 backcolor =
1414 let tmpprefix0 = (string_of_int (Unix.getpid ()))^"_"^md5 in
1515 let tmpprefix = (tmppath^"/"^tmpprefix0) in
1616 let unlink_all () =
@@ -30,7 +30,7 @@
3131 close_out f;
3232 if Util.run_in_other_directory tmppath (cmd_latex tmpprefix0) != 0
3333 then (unlink_all (); raise (ExternalCommandFailure "latex"))
34 - else if (Sys.command (cmd_dvipng tmpprefix (finalpath^"/"^md5^".png")) != 0)
 34+ else if (Sys.command (cmd_dvipng tmpprefix (finalpath^"/"^md5^".png") backcolor) != 0)
3535 then (if (Sys.command (cmd_dvips tmpprefix) != 0)
3636 then (unlink_all (); raise (ExternalCommandFailure "dvips"))
3737 else if (Sys.command (cmd_convert tmpprefix (finalpath^"/"^md5^".png")) != 0)
Index: trunk/phase3/math/README
@@ -48,13 +48,13 @@
4949
5050 === Command-line parameters ===
5151
52 - texvc <temp directory> <output directory> <TeX code> <encoding>
 52+ texvc <temp directory> <output directory> <TeX code> <encoding> <color>
5353
5454 Be sure to properly quote the TeX code!
5555
5656 Example:
5757
58 - texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1
 58+ texvc /home/wiki/tmp /home/wiki/math "y=x+2" iso-8859-1 "rgb 1.0 1.0 1.0"
5959
6060 === Output format ===
6161
Index: trunk/phase3/math/texvc.ml
@@ -3,7 +3,7 @@
44 try Lexer.token lexbuf
55 with Failure s -> raise (LexerException s)
66
7 -let render tmppath finalpath tree =
 7+let render tmppath finalpath tree backcolor =
88 let outtex = Util.mapjoin Texutil.render_tex tree in
99 let md5 = Digest.to_hex (Digest.string outtex) in
1010 begin
@@ -19,11 +19,11 @@
2020 | Some h,Html.LIBERAL,Some m -> "L" ^ md5 ^ h ^ "\000" ^ m
2121 | None,_,Some m -> "X" ^ md5 ^ m
2222 );
23 - Render.render tmppath finalpath outtex md5
 23+ Render.render tmppath finalpath outtex md5 backcolor
2424 end
2525 let _ =
2626 Texutil.set_encoding (try Sys.argv.(4) with _ -> "UTF-8");
27 - try render Sys.argv.(1) Sys.argv.(2) (Parser.tex_expr lexer_token_safe (Lexing.from_string Sys.argv.(3)))
 27+ try render Sys.argv.(1) Sys.argv.(2) (Parser.tex_expr lexer_token_safe (Lexing.from_string Sys.argv.(3))) (try Sys.argv.(5) with _ -> "rgb 1.0 1.0 1.0")
2828 with Parsing.Parse_error -> print_string "S"
2929 | LexerException _ -> print_string "E"
3030 | Texutil.Illegal_tex_function s -> print_string ("F" ^ s)
Index: trunk/phase3/includes/DefaultSettings.php
@@ -1895,6 +1895,13 @@
18961896 $wgUseTeX = false;
18971897 /** Location of the texvc binary */
18981898 $wgTexvc = './math/texvc';
 1899+/**
 1900+ * Texvc background color
 1901+ * use LaTeX color format as used in \special function
 1902+ * for transparent background use value 'Transparent' for alpha transparency or
 1903+ * 'transparent' for binary transparency.
 1904+ */
 1905+$wgTexvcBackgroundColor = 'rgb 1.0 1.0 1.0';
18991906
19001907 /**
19011908 * Normally when generating math images, we double-check that the
Index: trunk/phase3/includes/Math.php
@@ -33,7 +33,7 @@
3434
3535 function render() {
3636 global $wgTmpDirectory, $wgInputEncoding;
37 - global $wgTexvc, $wgMathCheckFiles;
 37+ global $wgTexvc, $wgMathCheckFiles, $wgTexvcBackgroundColor;
3838 $fname = 'MathRenderer::render';
3939
4040 if( $this->mode == MW_MATH_SOURCE ) {
@@ -63,7 +63,8 @@
6464 escapeshellarg( $wgTmpDirectory ).' '.
6565 escapeshellarg( $wgTmpDirectory ).' '.
6666 escapeshellarg( $this->tex ).' '.
67 - escapeshellarg( $wgInputEncoding );
 67+ escapeshellarg( $wgInputEncoding ).' '.
 68+ escapeshellarg( $wgTexvcBackgroundColor );
6869
6970 if ( wfIsWindows() ) {
7071 # Invoke it within cygwin sh, because texvc expects sh features in its default shell
Index: trunk/phase3/RELEASE-NOTES
@@ -290,6 +290,7 @@
291291 * (bug 20717) Added checkboxes to hide users with bot and/or sysop group
292292 membership in SpecialActiveusers
293293 * Allow \pagecolor and \definecolor in texvc
 294+* $wgTexvcBackgroundColor contains background color for texvc call
294295
295296 === Bug fixes in 1.16 ===
296297

Follow-up revisions

RevisionCommit summaryAuthorDate
r60992Per CR comments on r59593: use binary transparency for texvc by default. My t...tstarling22:57, 12 January 2010

Comments

#Comment by Tim Starling (talk | contribs)   05:47, 2 December 2009

Why isn't it transparent by default?

#Comment by Freakolowsky (talk | contribs)   07:08, 2 December 2009

I kept it at existing state (white bg) for now until it could be tested on all the IEs we wish to support. I personaly don't have any computer with IE <7 so i can not test it. But in general there's nothing stopping you from changeing to transparent.

#Comment by Tim Starling (talk | contribs)   07:50, 2 December 2009

OK, I'll set the status to fixme until the testing is done and the default is changed. Could you perhaps generate some test output and give URLs here so that whoever tests it on IE 6 doesn't need to get LaTeX working?

#Comment by Freakolowsky (talk | contribs)   08:11, 2 December 2009

http://www.abakus.si/jk/jksvn-ora/index.php?title=Math_Test ... using transparent (binary) http://www.abakus.si/jk/jksvn-my/index.php?title=Math_Test ... using Transparent (alpha)

might be a bit slow ATM, our sysadmin-apprentice decided 9am is a good time to do some work on cluster volumes :S

#Comment by Freakolowsky (talk | contribs)   08:34, 2 December 2009

hmmm ... noticed i have an onlder version of dvipng on the test server ... only Transparent (alpha) option is supported ... give me a minute to upgrade.

#Comment by Freakolowsky (talk | contribs)   11:13, 2 December 2009

having issues with dvipng ... made sth by-hand

here's a comparison testcase

http://www.abakus.si/abapub/pngtest.html

#Comment by Freakolowsky (talk | contribs)   15:58, 2 December 2009

http://www.abakus.si/jk/jksvn-my/index.php?title=Math_Test

and

http://www.abakus.si/jk/jksvn-ora/index.php?title=Math_Test

now use the same setup as wikipedia (dvipng 1.9)

compare page (http://www.abakus.si/abapub/pngtest.html) also updated

if binary version looks good enough to you, i'll switch default to binary transparency in DefaultSettings.php

k10xbai

#Comment by Freakolowsky (talk | contribs)   16:32, 2 December 2009

there are TWO links ... http://www.mediawiki.org/wiki/Special:Code/MediaWiki/59593#c4605 ... one for binary and one for alpha transparency and it seems to me you only tested the alpha part

#Comment by Platonides (talk | contribs)   17:40, 2 December 2009

Sorry. The "doesn't work" referred to alpha. It doesn't have issues with binary transparency. You may want to wait for testing with more browsers, though.

#Comment by Tim Starling (talk | contribs)   04:15, 3 December 2009

What about with the classic HTC transparency fix? http://www.twinhelix.com/css/iepngfix/

#Comment by Simetrical (talk | contribs)   19:28, 11 December 2009

My understanding is that gets very slow if you have dozens of images on the page, which is the case for equations. Someone should test that scenario before we use that.

#Comment by Freakolowsky (talk | contribs)   09:53, 8 December 2009

what now ... do i leave default at white background or switch to binary transparency?

#Comment by Simetrical (talk | contribs)   19:34, 11 December 2009

It's an aesthetic choice: we get either a giant white block around the text, or some fuzziness. Try setting it to binary transparency and then change the wiki background color to something other than white, and see how it looks. I can hardly notice the fuzziness, so I say go ahead and use binary transparency.

#Comment by Tim Starling (talk | contribs)   05:27, 12 January 2010

So $wgTexvcBackgroundColor = 'transparent'; in DefaultSettings.php?

#Comment by Simetrical (talk | contribs)   15:53, 12 January 2010

Yep.

#Comment by Simetrical (talk | contribs)   17:57, 19 February 2010

For the record, switched to binary transparency in r60992.

Status & tagging log