Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Wikipedia: Wikitech

Re: [MediaWiki] Enhancement: LaTeX images quality (eliminate white background)

 

 

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded


questpc at rambler

Nov 23, 2009, 12:53 AM

Post #1 of 9 (1191 views)
Permalink
Re: [MediaWiki] Enhancement: LaTeX images quality (eliminate white background)

* Aryeh Gregor <Simetrical+wikilist [at] gmail> [Thu, 19 Nov 2009
12:49:36 -0500]:
> We really don't want to increase the amount of non-PHP code in core
> unless absolutely necessary, IMO. PHP is an awful language, but it's
> the only thing that all current MediaWiki developers know. Anything
> else is much harder to maintain, because only some subset of people
> with commit access can competently alter it. I'm sure most committers
> know basic C syntax, but few would be confident enough to make
> significant changes to a C program (and if they tried they'd probably
> introduce giant memory leaks and such). Just a while ago, it took
> days to fix a simple XSS in Timeline because it was written in Perl.
>
> Besides, there's no need to reinvent the wheel. dvipng (which is
> apparently used here) should be able to do whatever we want, as far as
> I can tell. Failing that, ImageMagick or such would likely do the
> trick.
>
Recently I've come to interesting implementation of PHP in Java:
http://www.caucho.com/resin-3.0/quercus/
They claim it runs MediaWiki. Probably can be used for mixed PHP / Java
environment and for the smooth transition to Java?
Dmitriy

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


gtisza at gmail

Nov 29, 2009, 1:34 AM

Post #2 of 9 (1095 views)
Permalink
Re: [MediaWiki] Enhancement: LaTeX images quality (eliminate white background) [In reply to]

Aryeh Gregor <Simetrical+wikilist <at> gmail.com> writes:
> As far as I know, the only thing actually blocking us from doing this
> was something like IE5 on Mac printing transparent images with black
> backgrounds. That's probably not relevant anymore. We're still stuck
> with the fact that IE6 doesn't support alpha channels, though -- we
> could make the fully-transparent parts of the background transparent,
> but I don't see how we could avoid aliasing effects on sane browsers
> without making things look extremely ugly on IE6.

You could use PNG8 with a color palette where every color is black, with a
variable level of transparency. That would be equivalent to full PNG32 alpha
transparency in modern browsers (as long as the only color used in the formulas
is black), while IE5.5/6 would have binary transparency without any aliasing -
ugly but probably not horrible. (See
http://www.v-methods.com/ji/palette_alpha.html for a demonstration.)

Or you could just send different images to IE6, for example by using empty divs
with background images instead of img tags, and changing the image URL for IE6
with the star-html CSS hack. (Not very accessible, but maybe the text of the
formula could be written into the div with overflow:hidden?)


_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


alex.shulgin at gmail

Nov 29, 2009, 5:43 AM

Post #3 of 9 (1096 views)
Permalink
Re: [MediaWiki] Enhancement: LaTeX images quality (eliminate white background) [In reply to]

On Sun, Nov 29, 2009 at 11:34, Tgr <gtisza [at] gmail> wrote:
> Aryeh Gregor <Simetrical+wikilist <at> gmail.com> writes:
>> As far as I know, the only thing actually blocking us from doing this
>> was something like IE5 on Mac printing transparent images with black
>> backgrounds.  That's probably not relevant anymore.  We're still stuck
>> with the fact that IE6 doesn't support alpha channels, though -- we
>> could make the fully-transparent parts of the background transparent,
>> but I don't see how we could avoid aliasing effects on sane browsers
>> without making things look extremely ugly on IE6.
>
> You could use PNG8 with a color palette where every color is black, with a
> variable level of transparency. That would be equivalent to full PNG32 alpha
> transparency in modern browsers (as long as the only color used in the formulas
> is black), while IE5.5/6 would have binary transparency without any aliasing -
> ugly but probably not horrible. (See
> http://www.v-methods.com/ji/palette_alpha.html for a demonstration.)

Hey, that is something!

I thought of this possibility for using tRNS chunk with 8-bit black
PNG. But I discarded the idea because I didn't see a way for this to
work with black background in custom styles.

Now it appeared to me that by a simple change to any style featuring
black background we can overcome this last problem. Just put this
line in the style and it'll work like before:

img.tex { background-color: white; }

So, to sum it up:

1. Make PNGs for TeX formulas be of 8-bit indexed colors format with
tRNS chunk added.

The palette should contain all black pixels, except for single
reserved color which should be white (see below), i.e:

| Index | Color | tRNS |
| 0 | FF FF FF | 0 |
| 1 | 00 00 00 | 1 |
| 2 | 00 00 00 | 2 |
...
| 255 | 00 00 00 | 255 |

2. Add bKGD chunk containing the index of white color in palette (0).
This should make the image sensible for viewers other than browsers.

3. Modify currently used custom black style(s) to underlay white
background for TeX-only images as described above.

4. Document the change, make people prepared for it. :)

This seems to me like a comprehensible change which should make sense
to every browser (needs to be tested, though).

If everyone agrees on implementing this change you can count on me to
hack the low-level PNG-related stuff. :) We can try to hack dvipng to
add a new option for this or post-process the dvipng output, etc.

I'd really like to see this happen. Who is with me?

> Or you could just send different images to IE6, for example by using empty divs
> with background images instead of img tags, and changing the image URL for IE6
> with the star-html CSS hack. (Not very accessible, but maybe the text of the
> formula could be written into the div with overflow:hidden?)

This option looks error-prone and adds too much difficulty, IMHO.

--
Cheers!
Alex

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Simetrical+wikilist at gmail

Nov 29, 2009, 8:45 AM

Post #4 of 9 (1101 views)
Permalink
Re: [MediaWiki] Enhancement: LaTeX images quality (eliminate white background) [In reply to]

On Sun, Nov 29, 2009 at 4:34 AM, Tgr <gtisza [at] gmail> wrote:
> You could use PNG8 with a color palette where every color is black, with a
> variable level of transparency. That would be equivalent to full PNG32 alpha
> transparency in modern browsers (as long as the only color used in the formulas
> is black), while IE5.5/6 would have binary transparency without any aliasing -
> ugly but probably not horrible. (See
> http://www.v-methods.com/ji/palette_alpha.html for a demonstration.)

I thought of this, but the images would probably be too ugly for IE6
users to be acceptable. Remember, we're talking about making things
uglier for 15% of our users (everyone who uses IE6 on math articles)
for the benefit of well under 1% of our users (the ones who view
equations on non-white backgrounds in non-IE6 browsers). That's just
not a reasonable tradeoff. Either it has to be demonstrated that IE6
PNG transparency fixes perform well even on pages with lots of
equations, or people will just have to manually adjust background
colors if they really care.

I've whitelisted \definecolor and \pagecolor in r59550. I'm resolving
bug 8 as LATER, and suggest it only be reopened when either IE6
reaches <1% market share, or it can be demonstrated that we can do
transparency without significantly hurting IE6 users' experience when
reading math articles.

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Platonides at gmail

Nov 29, 2009, 2:29 PM

Post #5 of 9 (1099 views)
Permalink
Re: [MediaWiki] Enhancement: LaTeX images quality (eliminate white background) [In reply to]

Tgr wrote:
> Aryeh Gregor writes:
>> As far as I know, the only thing actually blocking us from doing this
>> was something like IE5 on Mac printing transparent images with black
>> backgrounds. That's probably not relevant anymore. We're still stuck
>> with the fact that IE6 doesn't support alpha channels, though -- we
>> could make the fully-transparent parts of the background transparent,
>> but I don't see how we could avoid aliasing effects on sane browsers
>> without making things look extremely ugly on IE6.
>
> You could use PNG8 with a color palette where every color is black, with a
> variable level of transparency. That would be equivalent to full PNG32 alpha
> transparency in modern browsers (as long as the only color used in the formulas
> is black), while IE5.5/6 would have binary transparency without any aliasing -
> ugly but probably not horrible. (See
> http://www.v-methods.com/ji/palette_alpha.html for a demonstration.)

It's a nice thing, but how is that relevant to the discussion about
texvc images?
Formulas don't need several transparency levels.
The problem of black background by browsers* ignoring the alpha channel
is solved by using a white background with alpha transparency. So people
not supporting the alpha channel, still see it white (for some reason,
image software like putting black as the color being 'transparent').

The problem there is people reading the wiki as "green on white".
They can use, img.tex { background-color: white; } to go back to how
they are now.

We can even modify the existing rendered files, if we want to avoid the
extremely unlikely case that there is some formula that hasn't been
stored at the math table in all these years.


*It's not just printing on IE6, the alpha channel is also ignored if you
open the image with simple software like paint.


_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Simetrical+wikilist at gmail

Nov 29, 2009, 2:38 PM

Post #6 of 9 (1088 views)
Permalink
Re: [MediaWiki] Enhancement: LaTeX images quality (eliminate white background) [In reply to]

On Sun, Nov 29, 2009 at 5:29 PM, Platonides <Platonides [at] gmail> wrote:
> It's a nice thing, but how is that relevant to the discussion about
> texvc images?
> Formulas don't need several transparency levels.

Yes, they do, if you want them to look good, because the fonts are antialiased.

> The problem of black background by browsers* ignoring the alpha channel
> is solved by using a white background with alpha transparency. So people
> not supporting the alpha channel, still see it white (for some reason,
> image software like putting black as the color being 'transparent').

This means that you'll still have a fuzzy white outline around the
text when you put it against a non-white background. However, you're
right that this will probably look better overall than the current
situation. It's worth considering.

> *It's not just printing on IE6, the alpha channel is also ignored if you
> open the image with simple software like paint.

I think we can ignore this issue.

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


freak at drajv

Nov 30, 2009, 6:50 AM

Post #7 of 9 (1082 views)
Permalink
Re: [MediaWiki] Enhancement: LaTeX images quality (eliminate white background) [In reply to]

Hey, don't get me wrong ... the current state works for me 100%, even if
wiki uses non-white background, i'm just throwing ideas here (and i do
realize it was a weak idea).

IMO these kind of tweaks should be in form of a cofigurable option so
people who want to use it and who think it won't screw up their system,
could use it. We should have an option to use alpha in PNG for math if
you think your wiki can exist without <IE6 compliance.

I'm NOT saying this should be used on WMF sites ... in fact i'm AGAINST
that. As much as it pains me to say this, all IE browsers still in
frequent use (if you can in fact call them browsers) should be supported.

That's all



Aryeh Gregor wrote:
> On Mon, Nov 30, 2009 at 8:44 AM, Freako F. Freakolowsky <freak [at] drajv> wrote:
>
>> Havent read the whole thread, but why not just do it the ol' school way.
>> Have texvc create two images one with alpha and the other without, and
>> then serve formula images depending on the user-agent.
>>
>
> Because that's a huge hassle for virtually zero benefit. You have to
> generate, store, and cache twice as many images, and implement some
> logic in Squid so it can serve different images to IE6 than everyone
> else (plain Vary: User-Agent would mean generating like four billion
> times as many images, not acceptable). On the other hand, the images
> will be *totally* *indistinguishable* for *virtually* *all*
> *articles*.
>
> The current situation is *really* not a big problem that's worth
> spending significant effort on.
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l [at] lists
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
>

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


Simetrical+wikilist at gmail

Nov 30, 2009, 8:02 AM

Post #8 of 9 (1084 views)
Permalink
Re: [MediaWiki] Enhancement: LaTeX images quality (eliminate white background) [In reply to]

On Mon, Nov 30, 2009 at 9:50 AM, Freako F. Freakolowsky <freak [at] drajv> wrote:
> Hey, don't get me wrong ... the current state works for me 100%, even if
> wiki uses non-white background, i'm just throwing ideas here (and i do
> realize it was a weak idea).
>
> IMO these kind of tweaks should be in form of a cofigurable option so
> people who want to use it and who think it won't screw up their system,
> could use it. We should have an option to use alpha in PNG for math if
> you think your wiki can exist without <IE6 compliance.
>
> I'm NOT saying this should be used on WMF sites ... in fact i'm AGAINST
> that. As much as it pains me to say this, all IE browsers still in
> frequent use (if you can in fact call them browsers) should be supported.
>
> That's all

As I said in bug 8, I'm totally in favor of a LocalSettings.php
configuration option for math background, if someone wants to write
the code. I even volunteered to review it, if it's short.

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l


freak at drajv

Nov 30, 2009, 10:42 AM

Post #9 of 9 (1076 views)
Permalink
Re: [MediaWiki] Enhancement: LaTeX images quality (eliminate white background) [In reply to]

here you go r59593 ... :D

Aryeh Gregor wrote:
> On Mon, Nov 30, 2009 at 9:50 AM, Freako F. Freakolowsky <freak [at] drajv> wrote:
>
>> Hey, don't get me wrong ... the current state works for me 100%, even if
>> wiki uses non-white background, i'm just throwing ideas here (and i do
>> realize it was a weak idea).
>>
>> IMO these kind of tweaks should be in form of a cofigurable option so
>> people who want to use it and who think it won't screw up their system,
>> could use it. We should have an option to use alpha in PNG for math if
>> you think your wiki can exist without <IE6 compliance.
>>
>> I'm NOT saying this should be used on WMF sites ... in fact i'm AGAINST
>> that. As much as it pains me to say this, all IE browsers still in
>> frequent use (if you can in fact call them browsers) should be supported.
>>
>> That's all
>>
>
> As I said in bug 8, I'm totally in favor of a LocalSettings.php
> configuration option for math background, if someone wants to write
> the code. I even volunteered to review it, if it's short.
>
> _______________________________________________
> Wikitech-l mailing list
> Wikitech-l [at] lists
> https://lists.wikimedia.org/mailman/listinfo/wikitech-l
>
>

_______________________________________________
Wikitech-l mailing list
Wikitech-l [at] lists
https://lists.wikimedia.org/mailman/listinfo/wikitech-l

Wikipedia wikitech RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.