# png2pdf

Convert PNG images to PDF

## Usage

PDF manual "png2pdf.pdf" available

### 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:

• -p pdf-level
--pdf=pdf-level
specifies the PDF level to use (may be "1.2", "1.3" or "1.4"). By default PDF 1.4 is produced.
• -a
-a-
--transparency=boolean
specifies whether or not to transfer an alpha channel from the PNG file into the PDF file.
• -i
-i-
specifies whether or not to convert the PNG alpha channel into a PDF image mask.
Note: alpha channel transfer and image mask creation can not be used at same time.
• -m RGB-triple
--mix-background=RGB-triple
mixes all pixels against the background color specified in the PNG file's background chunk. If there is no background chunk the RGB-triple is used.
Note: Mixing and alpha channel transfer (-a) can not be used at same time.
• -s
-s-
--mix-specified=boolean
sets priority for -m RGB-triple higher than PNG file background chunk. The -m RGB-triple is used always.
• -l
-l-
--invert-levels=boolean
inverts the trigger level used for image mask creation. By default only opacity=0 pixels are masked, inverting results in masking all pixels except those having full opacity.
• -t
-t-
--alpha-transparency=boolean
interprets alpha channel data as transparency instead of opacity.
• -n
--interpolation
adds an entry to the image dictionary indicating that viewers should attempt an image interpolation on the picture (see example).
Use with care. Different software may use different algorithms. The representation of the image may vary depending on the software and output device you use.
• -f
-f-
--file-time-check=boolean
enables/disables file time check when running on a directory. If file time check is enabled, a conversion is only started for PNGs which have have no corresponding PDF file or a PDF file older than the PNG file.
• -h
--help
prints a help text.
• -v
--version
prints version information.
• -c <options>
--configure <options>
sets options as permanent options, stored in the preferences system.
• -C
--show-configuration
prints a summary information about permanent options.
• -r <options>
--reset <options>
overrides (ignores) the permanent options for this one program invokation. The program starts based on compiled-in defaults and processes options given explicitely on the command line. This is intended for program usage in scripts where we want to have a well-defined startup.
• -u
--unconfigure
removes all permanent options.

### 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).