Discussion:
[Dvipng] Higher quality (smooth) PNGs?
U Avalos
2010-08-09 19:26:37 UTC
Permalink
Hi all. I am creating a hi-quality PDF by using Princexml to convert an HTML file (w/ LaTeX fragments) to a PDF. However, while the quality of the LaTex fragments created with dvipng look good on the computer screen, they do not *print* well. I tried increasing the output resolution (D switch). However, all that does is increase the pixel count---the images still appear pixelated and not smooth.

Is there a way to make the images more smooth? I tried using the Q switch (-Q 1 and -Q 10) but that doesn't seem to do anything. I'm using dvipng 1.12.

Perhaps I should be using something else to create the LaTeX images?

--Uriel
Jan-Åke Larsson
2010-08-09 20:13:34 UTC
Permalink
Post by U Avalos
Hi all. I am creating a hi-quality PDF by using Princexml to convert an HTML file (w/ LaTeX fragments) to a PDF. However, while the quality of the LaTex fragments created with dvipng look good on the computer screen, they do not *print* well. I tried increasing the output resolution (D switch). However, all that does is increase the pixel count---the images still appear pixelated and not smooth.
This is because they are pixelated, and intended for no other purpose
than screen output.
Post by U Avalos
Is there a way to make the images more smooth? I tried using the Q switch (-Q 1 and -Q 10) but that doesn't seem to do anything. I'm using dvipng 1.12.
If your dvipng uses FreeType, the -Q switch does nothing. The -Q switch
controls the quality of the old PK fonts.
Post by U Avalos
Perhaps I should be using something else to create the LaTeX images?
Yes. I'd suggest making PDF snippets out of them and include those in
the PDF at the appropriate places.

Best of luck
/JÅ
U Avalos
2010-08-10 13:21:01 UTC
Permalink
Thanks for the reply.

However, I'm not really a LaTeX person. How would I go about making PDF fragments?

FYI, I'm in an emacs environment---I type in org-mode (a text file, basically), then emacs takes care of exporting embedded LaTeX fragments to PNGs (using a hack of the preview-latex package, I believe).

Also, FYI. Just a hunch but it appears that dvipng may now be used for other purposes other than quick-and-dirty previews in emacs. (Ex: dvipng's own webpage says that it's used in wikipedia). It may be time to add an option for smooth images... or maybe another program can easily provide the same functionality...

On Mon, 9 Aug 2010 22:13:34 +0200
Post by Jan-Åke Larsson
Post by U Avalos
Hi all. I am creating a hi-quality PDF by using Princexml to convert an HTML file (w/ LaTeX fragments) to a PDF. However, while the quality of the LaTex fragments created with dvipng look good on the computer screen, they do not *print* well. I tried increasing the output resolution (D switch). However, all that does is increase the pixel count---the images still appear pixelated and not smooth.
This is because they are pixelated, and intended for no other purpose
than screen output.
Post by U Avalos
Is there a way to make the images more smooth? I tried using the Q switch (-Q 1 and -Q 10) but that doesn't seem to do anything. I'm using dvipng 1.12.
If your dvipng uses FreeType, the -Q switch does nothing. The -Q switch
controls the quality of the old PK fonts.
Post by U Avalos
Perhaps I should be using something else to create the LaTeX images?
Yes. I'd suggest making PDF snippets out of them and include those in
the PDF at the appropriate places.
Best of luck
/JÅ
_______________________________________________
Dvipng mailing list
http://lists.nongnu.org/mailman/listinfo/dvipng
--
--Thanks!
Uriel
Jan-Åke Larsson
2010-08-10 14:34:15 UTC
Permalink
Post by U Avalos
However, I'm not really a LaTeX person. How would I go about making PDF fragments?
Since I usually produce PDFs through dvips->ps2pdf I am probably not the
best person to answer this. I'd assume producing single-page EPS files
and shoving them through eps2pdf?
Post by U Avalos
FYI, I'm in an emacs environment---I type in org-mode (a text file, basically), then emacs takes care of exporting embedded LaTeX fragments to PNGs (using a hack of the preview-latex package, I believe).
A (suboptimal) solution would be to produce high-resolution PNGs
(-D 1200) and shrink them to the appropriate size. This would probably
look terrible onscreen but better on the printer. I don't know enough
details about the surrounding system you use to be more specific.
Post by U Avalos
Also, FYI. Just a hunch but it appears that dvipng may now be used for other purposes other than quick-and-dirty previews in emacs. (Ex: dvipng's own webpage says that it's used in wikipedia). It may be time to add an option for smooth images... or maybe another program can easily provide the same functionality...
I wrote that. And part of the WikiMedia code. Problem is, PNGs are pixel
images, there is just no way around that. The solution would be to use a
vector-based format.

Best
/JÅ
U Avalos
2010-08-11 15:53:38 UTC
Permalink
For reference (for anyone stumbling upon this thread), I stumbled upon a solution using dvips and imagemagick:

(1) Convert the dvi to a ps: dvips -E <dvifile>
(2) Convert the ps to a PNG: convert -density 300 -resample 300 <psfile> <pngfile>.PNG

While the resulting images are too large on the screen, they *print* out just fine (which is the goal)---about 12 pt tall and very smooth. The print quality is much better than dvipng. Of course, the conversion process is much slower (for print, we don't really care about speed so that's OK).

Unfortunately, I'm at a loss to explain why this method works so I don't know if it can be improved...



On Tue, 10 Aug 2010 16:34:15 +0200
Post by Jan-Åke Larsson
Post by U Avalos
However, I'm not really a LaTeX person. How would I go about making PDF fragments?
Since I usually produce PDFs through dvips->ps2pdf I am probably not the
best person to answer this. I'd assume producing single-page EPS files
and shoving them through eps2pdf?
Post by U Avalos
FYI, I'm in an emacs environment---I type in org-mode (a text file, basically), then emacs takes care of exporting embedded LaTeX fragments to PNGs (using a hack of the preview-latex package, I believe).
A (suboptimal) solution would be to produce high-resolution PNGs
(-D 1200) and shrink them to the appropriate size. This would probably
look terrible onscreen but better on the printer. I don't know enough
details about the surrounding system you use to be more specific.
Post by U Avalos
Also, FYI. Just a hunch but it appears that dvipng may now be used for other purposes other than quick-and-dirty previews in emacs. (Ex: dvipng's own webpage says that it's used in wikipedia). It may be time to add an option for smooth images... or maybe another program can easily provide the same functionality...
I wrote that. And part of the WikiMedia code. Problem is, PNGs are pixel
images, there is just no way around that. The solution would be to use a
vector-based format.
Best
/JÅ
_______________________________________________
Dvipng mailing list
http://lists.nongnu.org/mailman/listinfo/dvipng
--
--Thanks!
Uriel
Jan-Åke Larsson
2010-08-12 09:52:41 UTC
Permalink
Hi,
I have been looking closer at this, and on one machine, I have noticed
that palette images from dvipng does not use antialiasing. Perhaps this
is your problem. In that case, try adding

--truecolor

to your dvipng call. This would produce antialiased images even on that
machine. I will investigate the reason for this behavior and return as
soon as I can.

/JÅ
Jan-Åke Larsson
2010-08-12 11:22:22 UTC
Permalink
A closer look shows that certain programs used to display the images (I
use different programs on different machines) do not handle
alpha-channel antialiasing in palette images. Bad. Probably this is what
affects your printer as well.

I'll think about this but it is likely that the default behaviour of
dvipng will change: Alpha-channel antialiasing (~full alpha
transparency) will force truecolor output, much as image inclusion does
already.

So do use the --truecolor switch for now, that should solve your problem.


Best
/JÅ
Post by Jan-Åke Larsson
Hi,
I have been looking closer at this, and on one machine, I have noticed
that palette images from dvipng does not use antialiasing. Perhaps this
is your problem. In that case, try adding
--truecolor
to your dvipng call. This would produce antialiased images even on that
machine. I will investigate the reason for this behavior and return as
soon as I can.
/JÅ
U Avalos
2010-08-17 15:12:05 UTC
Permalink
Sorry for the delay.

A quick test shows no noticeable change in quality. In fact, the resulting images look the same.

I created two sets of images, one using the "usual" switches and another using the "truecolor" switch.

On the computer screen, both latex fragments look the same.

I then converted the files to PDFs and printed them. Again, both latex fragments look the same.

If there's a difference, I can't spot it.

On Thu, 12 Aug 2010 13:22:22 +0200
Post by Jan-Åke Larsson
A closer look shows that certain programs used to display the images (I
use different programs on different machines) do not handle
alpha-channel antialiasing in palette images. Bad. Probably this is what
affects your printer as well.
I'll think about this but it is likely that the default behaviour of
dvipng will change: Alpha-channel antialiasing (~full alpha
transparency) will force truecolor output, much as image inclusion does
already.
So do use the --truecolor switch for now, that should solve your problem.
Best
/JÅ
Post by Jan-Åke Larsson
Hi,
I have been looking closer at this, and on one machine, I have noticed
that palette images from dvipng does not use antialiasing. Perhaps this
is your problem. In that case, try adding
--truecolor
to your dvipng call. This would produce antialiased images even on that
machine. I will investigate the reason for this behavior and return as
soon as I can.
/JÅ
--
--Thanks!
Uriel
Loading...