\chapter{Images} \section{To Convert a PDF to an Image}\index[concepts]{pdf documents}\index[concepts]{pdf documents!converting to images} \lettrine[]{U}{se} the \texttt{pdftoppm}\index{pdftoppm} command (from the \label{poppler-utils} \texttt{poppler-utils}\index{poppler-utils} package) to convert part or all of a pdf to an image. For example, to convert a pdf to a png: \begin{Verbatim}[frame=single, breaklines=true] pdftoppm input.pdf output -png \end{Verbatim} This will convert each page in the pdf to a png using the format ``output-01.png'' where ``01'' is the page number. To convert a single page of a multipage pdf, use the \texttt{-f} flag to specify which page to use. For example, this will convert page 5 to a png: \begin{Verbatim}[frame=single, breaklines=true] pdftoppm input.pdf output -png -f 5 -singlefile \end{Verbatim} To convert a range of pages, use the \texttt{-f} flag to specify the first page to convert and use the \texttt{-l} flag to specify the last page of the range: \begin{Verbatim}[frame=single, breaklines=true] pdftoppm input.pdf output -png -f 5 -l 10 -singlefile \end{Verbatim} The default resolution is 150 dpi. To change this, use the \texttt{-rx} flag to specify the resolution along the x-axis, and the \texttt{-ry} flag to specify the resolution along the y-axis; \begin{Verbatim}[frame=single, breaklines=true] pdftoppm input.pdf output -png -rx 300 -ry 300 \end{Verbatim} Doubling the resolution along both axes will increase the file size by an approximate factor of four, and will also increase the amount of detail in the image. \ktcbox{When creating \LaTeX{} tutorials for the web, I will generally use the \texttt{standalone} class and then convert the resulting pdf to a png image for use with html.} \section{To Extract Images from a PDF File}\index[concepts]{images!extracting}\index[concepts]{pdf documents!extracting images from} \lettrine[findent=0mm]{T}{o} extract images from a pdf file, use the \texttt{pdfimages}\index{pdfimages} command (also from the same package\index{poppler-utils} mentioned in \S \ref{poppler-utils} ). As before, the \texttt{-f} flag denotes the first page you want to extract image files from and the \texttt{-l} flag denotes the last page to extract image files from. Omitting them both will extract images from all pages.\index[concepts]{images} By default, images are saved as PBM (for monochrome images),\index[concepts]{images!monochrome} PGM (for grayscale images),\index[concepts]{images!grayscale} or PPM (for color images)\index[concepts]{images!color} files. Use the \texttt{-j} flag to save them as \texttt{jpeg} files or the \texttt{-J} flag to save them as \texttt{jpeg 2000}\index[concepts]{images!jpeg 2000} files. The \texttt{-list} flag will send a list of image information to \texttt{stdout} including the image file name, the page number, the image dimensions and resolution, the color space type, and the color depth\index[concepts]{color depth}\index[concepts]{bits per component} (i.e., bits per component). If needed, this can redirected to a text file. To generate the list without generating any images, use the \texttt{-listonly} flag.