png2pdf

SourceForge.net Logo
Convert PNG images to PDF

Usage

PDF manual "png2pdf.pdf" available
Overview
Options
Example
Original image and pdfLaTeX source
PDF image, white background
Background color
Background effects

Overview

The program can be invoked by typing

  png2pdf [<options>]
  png2pdf [<options>] <input-file> <output-file>
  png2pdf [<options>] <directory>
If no file name is specified the program runs on the current directory. When running on a directory the program checks the directory for PNG file and converts all PNG files to PDF.

Options

The following options can be used:

Examples

Original image and pdfLaTeX source

In the examples the image stefan_255_rgba.png from the PNG web site is used.

 
If the image is included into a pdfLaTeX source

  \documentclass[12pt,a4paper,titlepage]{article}
  \usepackage{ifpdf}        % LaTeX or pdfLaTeX
  \usepackage{color}        % we want to use background color
  \usepackage{graphicx}
  \ifpdf
  \usepackage{background}   % for the background effects, PPower4 necessary
  \fi
  \definecolor{bgred}{rgb}{1.0,0.501961,0.501961}
  ...
  \begin{document}
  ...
  \begin{figure}
  {\centering
  \includegraphics[width=5cm]{stefan_255_rgba.png}
  \caption{Some caption}
  \label{fig:some-label}
  }
  \end{figure}
  ...
  \end{document}
the result looks like shown in image 1:
 

 

PDF image, white background

If we create a PDF file using

  png2pdf -m 255,255,255 -s stefan_255_rgba.png x1.pdf
and change the pdfLaTeX source to
  ...
  \begin{figure}
  {\centering
  \includegraphics[width=5cm]{x1.pdf}
  \caption{Some caption}
  \label{fig:some-label}
  }
  \end{figure}
  ...
the result looks like shown in image 2:
 

Background color

To obtain a colored background we add

  \pagecolor{bgred}
to the pdfLaTeX source and run the conversion
  png2pdf -m 255,128,128 -s stefan_255_rgba.png x1.pdf
The result is shown in image 3:
 

Background effects

Now we use

  \vpagecolor{bgred}
to produce a background effect. Note: Post-processing using PPower4 is necessary to make the effect visible.
Using the existing image x1.pdf produces output as shown in figure 4:
 

 
A red rectangle shows the extents of the image.
Toe remove the rectange we create an image mask while converting the picture using
  png2pdf -m 255,128,128 -s -i stefan_255_rgba.png x1.pdf
Output is shown in image 5. There is still some kind of border around the shadow.
 

 
So we decide to transfer the alpha channel from the PNG file into the PDF file using
  png2pdf -m 255,128,128 -s -a stefan_255_rgba.png x1.pdf
Output is now as expected (image 6).