bmeps SourceForge.net Logo
Converter from PNG/JPEG/NetPBM to EPS and PDF

Examples

PDF manual "bmeps.pdf" available
german PDF manual "bmepsde.pdf" available
Example data
Example image
Example LaTeX source
Convert files before running LaTeX/pdfLaTeX
PS level 1
PS level 2
PS level 2 over colored background
Mixing against the background color
PS level 3 and image mask
PDF and alpha channel transfer
Convert files ``on the fly'' while dvips runs
Make sure dvips is running in secure mode by default
Use \DeclareGraphicsRule
Create the bounding boxes
Set up draft mode
Run latex and dvips
Deactivate draft mode, run final dvips

Example data

Example image

In the examples we use a partially transparent PNG file fbt.png containing a clock showing 5 minutes before 12. The image contains a radial alpha gradient, it is fully opaque in the center and fully transparent in the corners. The table below shows the image in front of different background colors.

Example LaTeX source

The LaTeX source for the examples is a one-foil beamer presentation:

\documentclass{beamer}
\mode<presentation>{\usetheme{Madrid}
\setbeamercovered{transparent}}
\usepackage[german]{babel}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{ifpdf}
\usepackage{graphicx}
\usepackage{color}
\ifpdf
\hypersetup{pdfpagemode=FullScreen}
\fi
\title[Beamer and bmeps]{Using bmeps with the beamer class}
\author[Krause]{D.~Krause}
\subject{bmeps}
\begin{document}
% \beamertemplateshadingbackground{yellow!50}{magenta!50}
\begin{frame}
\frametitle{Image over white background}
\includegraphics[width=5cm]{fbt1}
\end{frame}
\end{document}
While processing the examples we will change the background to yellow and later into a blue-to-yellow transition, the file name of the included graphics also changes.

Convert files before running LaTeX/pdfLaTeX

PS level 1

The commands

bmeps -leps1 fbt.png fbt1.eps
latex bt1 && latex bt1 && latex bt1
produce EPS level 1 output.

PS level 2

The commands

bmeps -l eps2 fbt.png fbt2.eps
latex bt2 && latex bt2 && latex bt2
produce EPS level 2 output. The output is colored now, but the file size is much smaller than fbt1.eps because PS level 2 provides better compression and encoding algorithms.

PS level 2 over colored background

If we change the presentations background color to yellow and run

latex bt3 && latex bt3 && latex bt3
the image of the background is unchanged white because the colors in the EPS file did not change.

Mixing against the background color

The yellow color is expressed hexadecimally as 0xff, 0xff and 0x7f. The conversion to the range [0;1] results in 1, 1, 0.5.
To create fbt3.eps we mix against a background color (m=y), the default background color is 1:1:0.5 (b=1.0:1.0:0.5) and the default background color is always used (a.u.d.b=y) ignoring background color information from the input file.

bmeps -leps2,m=y,b=1.0:1.0:0.5,a.u.d.b=y fbt.png fbt3.eps
latex bt4 && latex bt4 && latex bt4

PS level 3 and image mask

Now we use a blue-to-yellow transition as background in the presentation. In addition to mixing the alpha channel from the input file is converted into an image mask.

bmeps -leps3,m=y,b=1.0:1.0:0.5,a.u.d.b=y,c.i.m=y fbt.png fbt4.eps
latex bt5 && latex bt5 && latex bt5

PDF and alpha channel transfer

To make the image partially transparent (the presentation background is partially visible through the image) we need to transfer the alpha channel to the output. This is possible for PDF level 1.4 output only.
First we attempt to include the fbt.png image directly

\includegraphics[width=5cm]{fbt}
and run
pdflatex bt6 && pdflatex bt6 && pdflatex bt6
The result

shows that pdflatex does not yet handle alpha channel data as we want it.
So we have to convert the file manually to fbt5.pdf and include that file.
\includegraphics[width=5cm]{fbt5.pdf}
bmeps -lpdf fbt.png fbt5.pdf
pdflatex bt6 && pdflatex bt6 && pdflatex bt6