Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

dvips + png + bmpsize

191 views
Skip to first unread message

Ulrike Fischer

unread,
Nov 27, 2007, 11:16:28 AM11/27/07
to
Hello,

the dvips in miktex is able to handle png (and other bitmaps) with
the help of the bmeps-library.

The package bmpsize can retrieve sizes of png-graphics (and so avoid
extra .bb-files).

But I don't seem to be able to benefit from both because they expect
different \DeclareGraphicsRules:

I can process the following document with Latex+dvips if test.bb
exists:

\documentclass[dvips]{article}
\usepackage{graphicx}

\DeclareGraphicsRule{.png}{eps}{.bb}{}
\begin{document}
\includegraphics{test.png}
\end{document}

Without test.bb I can run latex if I use another rule, but then
dvips fails:

\documentclass[dvips]{article}
\usepackage{graphicx}
\usepackage{bmpsize}
\DeclareGraphicsRule{.png}{bmp}{.bb}{}
%\DeclareGraphicsRule{.png}{eps}{.bb}{}
\begin{document}
\includegraphics{test.png}
\end{document}

Is there a way to reconcile the both?

--
Ulrike Fischer

tlhiv

unread,
Nov 27, 2007, 11:46:02 AM11/27/07
to
Ulrike,

As you've already mentioned, PNG's are supported. I, however, prefer
to use *ONLY* EPS graphics when using LaTeX and PDF graphics when
using PDFLaTeX. sam2p is a nice utility for converting raster images
(e.g., PNG) to EPS/PDF because it does an outstanding job of placing a
"vector wrapper" around the raster image without (significantly)
changing the data.

You can get sam2p at

http://www.inf.bme.hu/~pts/sam2p/

or you can use my sam2p web interface at

http://www.tlhiv.org/rast2vec/

to convert your PNG's. Once you have converted them, you should be
able to do

\usepackage{graphicx}
...
\includegraphics{foo}

and LaTeX will assume foo.eps and PDFLaTeX should assume foo.pdf.
PDFLaTeX may try to use your PNG if it's in the same directory, so you
might just want to move it. Omitting the file extension is a way of
having the same document compile with both LaTeX and PDFLaTeX. The
downside is that a EPS and PDF version of the graphic are needed for
this flexibility.

You might also want to read the article I wrote on graphics and LaTeX
at

http://www.tlhiv.org/graphics/

Troy Henderson

Heiko Oberdiek

unread,
Nov 28, 2007, 6:27:54 AM11/28/07
to
Ulrike Fischer <ne...@nililand.de> wrote:

In theory yes. However I don't know the best way in practice.
because I am not using MikTeX (because of Linux as OS) and
I was able to find documentation about the bmeps integration
in dvips.
bmpsize supports the .bmp, .pcx, and .msp using
the em:graph special. These graphics types are supported
by native dvips. It seems logical to me to use the same method
for other bitmap graphics files like PNG or JPEG, e.g.
\special{em:graph test.png,24.08957pt,24.08957pt}
Why does it not work for your dvips? It looks like a bug to me.

Also bmeps seems to support more options, converting to grayscale, ...
Is this supported by dvips?

How does the conversion work in dvips? Are there PostScript files
that are input in the final result or is this done in a transparent
manner?

Yours sincerely
Heiko <ober...@uni-freiburg.de>

Ulrike Fischer

unread,
Nov 28, 2007, 8:33:10 AM11/28/07
to
Am Wed, 28 Nov 2007 12:27:54 +0100 schrieb Heiko Oberdiek:


>> the dvips in miktex is able to handle png (and other bitmaps) with
>> the help of the bmeps-library.
>>
>> The package bmpsize can retrieve sizes of png-graphics (and so avoid
>> extra .bb-files).
>>
>> But I don't seem to be able to benefit from both because they expect
>> different \DeclareGraphicsRules:

...
>> \DeclareGraphicsRule{.png}{eps}{.bb}{} %for dvips
>> \DeclareGraphicsRule{.png}{bmp}{.bb}{} % for bmpsize
...

>> Is there a way to reconcile the both?
>
> In theory yes. However I don't know the best way in practice.
> because I am not using MikTeX (because of Linux as OS) and
> I was able to find documentation about the bmeps integration
> in dvips.

I guess that means "wasn't able". ;-)

> bmpsize supports the .bmp, .pcx, and .msp using
> the em:graph special. These graphics types are supported
> by native dvips. It seems logical to me to use the same method
> for other bitmap graphics files like PNG or JPEG, e.g.
> \special{em:graph test.png,24.08957pt,24.08957pt}
> Why does it not work for your dvips? It looks like a bug to me.

I don't know. If I try to use dvips on a document that used
\DeclareGraphicsRule{.png}{bmp}{.bb}{}

I get the error message:

This is dvips(k) 5.95b Copyright 2005 Radical Eye Software
(www.radicaleye.com)
' TeX output 2007.11.28:1244' -> test2.ps
<tex.pro><texps.pro><special.pro>. <cmr10.pfb>[1] [2
dvips.exe: em:graph: IMG_1250.png: unsupported graphics file type
]
Drücken Sie eine beliebige Taste . . .

But I don't have the newest miktex, so it is naturally possible that
the problem isn't there anymore. On the other side, the bmeps page
states cleary that the type eps should be used in the rule.

>
> Also bmeps seems to support more options, converting to grayscale, ...
> Is this supported by dvips?

I don't know. I didn't make much tests. Perhaps is is possible to
use the configuration file also with dvips. dvips itself says:

% libbmeps EPS output and bitmap conversion library 1.1.0
(SCCS=1.73)
% (PNG, JPEG, NETPBM)
% libpng The PNG reference library
% jpegsrc The Independent JPEG Group's free JPEG software
% netpbm The image conversion toolkit
% zlib General purpose compression library

> How does the conversion work in dvips? Are there PostScript files
> that are input in the final result or is this done in a transparent
> manner?

I'm not sure. From the homepage of bmeps I got the impression that
the integrated library in dvips simply converts "on-the-fly" the
bitmaps to eps. So I think it does make sense that for the
processing with dvips the bitmap's should use the rule for the
"eps"-type.

I guess the only way to handle this would be to set the rule to type
bmp, let bmpsize get the size of the image, save the values somehow,
then reset the rule to type eps and then use the saved values as
bounding box -- probably it is less trouble to make the .bb before.
;-)


Btw: It is not a pressing issue. I got only curious due to a
discussion on the miktex mailing list.

--
Ulrike Fischer

Dirk Krause

unread,
Nov 30, 2007, 7:59:02 AM11/30/07
to
Ulrike Fischer <ne...@nililand.de> wrote in news:10ummfqtcsttz
$.d...@nililand.de:

> Hello,
>
> the dvips in miktex is able to handle png (and other bitmaps) with
> the help of the bmeps-library.
>
> The package bmpsize can retrieve sizes of png-graphics (and so avoid
> extra .bb-files).

Hello Ulrike,
the bmeps used by MikTeX's dvips is a very old version.
You should better use a recent version, bmeps 2.0.3 for Windows is
included in the dklibs library set for Windows. At
http://sourceforge.net/projects/dklibs go to the download section
and get dklibs-win32-1.1.48-user-setup.exe.
The on-the-fly conversion saves disk space but repeats the conversion
each time you run dvips. You should use this feature only if there is
not enough hard disk space available to hold EPS versions of your
images.
The PNGs I use are mostly screenshots. Bmeps version 2.x.x produces much
smaller files for these PNGs than version 1.x.x so it should not be a
problem to have EPS versions on disk too.
The version 2.x.x can run on directories to convert all supported
images (support for PNG, JPEG, NetPBM and partial TIFF support is
compiled into the Windows binary). The special make-like mode only
runs a conversion if necessary (image.eps does not exist or the
last modification was applied before the last modification was
applied to image.png).
Run
bmeps -leps2 -m- .
once.
Each time before you run latex, run
bmeps -leps2 -m .
I would not recommend to mix DeclareGraphicsRules for bmeps and
for bmpsize as they possibly use different image resolutions.
Bmeps converts one PNG pixel to one PS point (this is a resolution
of 72dpi), the ebb program uses a resolution of 150dpi. I do not
know which resolution bmpsize uses, but if it differs from 72dpi
you will get wrong bounding boxes. For images converted to PS
using bmeps (either on the fly or by command line) use bmeps for
the bounding box calculation too, i.e. for bmeps 2.x.x run
bmeps -lbb -m- .
to create the bounding box files for all images in the current
directory.
Regards,

Dirk

--
Please do not use the e-mail address dev...@fh-schmalkalden.de to
contact me, use the web interface at
http://www.fh-schmalkalden.de/url.php?/page/1026/select_wert/3023
instead. Thanks.

Heiko Oberdiek

unread,
Nov 30, 2007, 1:31:41 PM11/30/07
to
Dirk Krause <dev...@fh-schmalkalden.de> wrote:

> I would not recommend to mix DeclareGraphicsRules for bmeps and
> for bmpsize as they possibly use different image resolutions.
> Bmeps converts one PNG pixel to one PS point (this is a resolution
> of 72dpi), the ebb program uses a resolution of 150dpi.

My knowledge is 100 DPI for ebb (dvipdfm(x)).

> I do not know which resolution bmpsize uses,

The resolution of the bitmap file, if the resolution data are
available, otherwise a default resolution is used. The
behaviour can be configured, see documentation.
This allows fixed resolutions for mimiking the behaviour
of ebb.

Yours sincerely
Heiko <ober...@uni-freiburg.de>

0 new messages