bmeps

SourceForge.net Logo
Convert PNG/JPEG/NetPBM to EPS

Usage

PDF manual "bmeps.pdf" available
Command line options
Program invokation
Bounding box creation
Image conversion options
Usual conversion options
Alpha channel handling
Obtaining resolution from PNG pHYs chunk
Draft option
Option examples
EPSOUTPUT environment variable
Contents
Examples
How to use bitmap graphics in LaTeX
Declaring the file type
Unmodified dvips
Modified dvips
Run dvips
LaTeX examples
Example sources
Example outputs

Command line options

Program invokation

The program is invoked by

  bmeps [<options>] [ <input-file> [<output-file>] ]
If no output-file is specified output goes to standard output. If the input-file argument is omitted too, input is read from standard input, the program runs as a filter. In this case it is necessary to use the -t option to specify the file type (see below).

Bounding box creation

The -b option can be used to generate a bounding box file as it is needed by LaTeX, i.e.

  bmeps -b image.png image.bb
reads a PNG file image.png and writes a bounding box file image.bb.

Image conversion options

Usual conversion options

Alpha channel handling

Obtaining resolution from PNG pHYs chunk

If you want to use the same resolution in the EPS output file as specified in the PNG files pHYs chunk (if there is one), use the -q option.
This feature was implemented on one user's request for special purposes and is not yet well-tested. Normally you should not use it as scaling the image is left up to LaTeX or a DTP application of your choice. But the feature might be usefull to create EPS images for standalone viewing.
This feature is new and not yet well-tested.

Draft option

Using the -d option runs the program in draft mode, no image conversion is done, a grey rectangle is printed instead.

Options examples

  bmeps -p 2 -g -e r8 image.png image.eps
converts file image.png to image.eps. EPS level 2 is used, greyscaled output is enforced. Run-length-compression and ASCII-85-encoding are used to produce the smallest possible output file.
This option set is a typical example when printing on a PS-level-2 printer.
 
  bmeps -p3 -c -e8rf -am128,255,255s image.png image.eps
converts image.png to image.eps. EPS level 3 is used, output is coloured. A combination of all compression/encoding mechanisms available in EPS level 3 is used.
If image.png contains an alpha channel, this is used to produce an EPS image mask. In addition to building an image mask the colours are mixed against a light green background, a PNG background colour chunk is ignored.

EPSOUTPUT environment variable

Contents

To establish default settings one can use the EPSOUTPUT environment variable.
The value of this variable is a string consisting of the following:

Examples how to use the EPSOUTPUT environment variable

  EPSOUTPUT=2g8r
  export EPSOUTPUT
can be used in a Bourne-Shell or derivate to set up EPS level 2, greyscaled output, run-length compression and ASCII-85-encoding.
 
  setenv EPSOUTPUT 3c8rfa128,255,128s
can be used in a C-Shell or derivate to set up for EPS level 3, coloured output, maximum compression by use of run-length compression, flate compression and ASCII-85-encoding.
If the PNG file contains an alpha channel an image mask is created, additionally each pixels colour is mixed against a light green background. Background chunks in the PNG file are ignored.
 
  set EPSOUTPUT=d
can be used on the DOS-prompt to set draft mode.

How to use bitmap graphics in LaTeX

Declaring the file type

Unmodified dvips, runs bmeps if necessary

By default LaTeX does not accept PNG/JPEG/NetPBM graphics, we must declare graphics rules for these file types.
In the document preamble write

  \DeclareGraphicsRule{.png}{eps}{.bb}{`bmeps #1}
This tells LaTeX that files having suffix .png can be converted to EPS. The bounding box for such a file is specified in a file having the same name but suffix .bb.
When dvips comes to a place to insert an image, it runs the bmeps program for the specified .png file. No output file name is specified in the command so bmeps writes to standard output which is read by dvips and transferred into the final output .ps file.

Modified dvips, internal conversion

If you have a modified dvips available, the graphics rule looks like

  \DeclareGraphicsRule{.png}{eps}{.bb}{}
There is no need for dvips to run an external conversion program.

Running dvips

Before running dvips you should set the EPSOUTPUT variable.
If you have a modified dvips available, you can also specify conversion options using the -I option, i.e.

  dvips -I 2g8r ...

LaTeX examples

Example sources

The EXAMPLES subdirectory contains Postscript files derived from the same example.tex file using different options.
The image stefan_255_rgba.png was obtained from the "Miscallenous Transparent PNGs Using Image Tags" page on the libpng home page.
ImageLaTeX source

 
Some levels of gray in this image are produced by specifying a black foreground, a white background and an alpha channel value for mixing.
 
\documentclass[titlepage,12pt]{article}
\usepackage{a4}
\usepackage{geometry}
\usepackage[T1]{fontenc}
\usepackage{times}
\usepackage[latin1]{inputenc}
\parindent0cm
\usepackage{longtable}
\usepackage{varioref}
\usepackage{makeidx}
\usepackage{graphicx}
\usepackage{hyperref}
\usepackage[dvips]{color}
%
% The pagecolor instruction in the line below was used
% to produce the bg...ps files.
%
% \pagecolor{cyan}

% \DeclareGraphicsRule{.png}{eps}{.bb}{`bmeps #1}
\DeclareGraphicsRule{.png}{eps}{.bb}{}

\geometry{body={17cm,22cm},top=1cm,left=2.5cm}
\makeindex
\begin{document}
\begin{sloppy}
\section{Example}
The options \texttt{1g} were used to create this file.
\begin{figure}
\begin{center}
\caption{Bird}
\includegraphics[width=4cm]{stefan_255_rgba.png}
\end{center}
\end{figure}
\end{sloppy}
\end{document}

Example outputs

 
Now we show how to deal with the alpha channel.
The line
\pagecolor{cyan}
in the TeX source file was activated to establish a page background color.
 
To create a draft file using placeholders for bitmap images only one can use the d option, a result is shown in d.ps.