Document -list-images[-json]

This commit is contained in:
John Whitington 2024-01-27 13:39:45 +00:00
parent 9d9da10471
commit e797eca681
2 changed files with 57 additions and 9 deletions

Binary file not shown.

View File

@ -3611,8 +3611,16 @@ The \texttt{-dump-attachments} operation, when given a PDF file and a directory
\noindent\small\verb!cpdf -extract-images in.pdf [<range>] [-im <path>] [-p2p <path>]!
\noindent\small\verb! [-dedup | -dedup-perpage] [-raw] -o <path>!
\vspace{1.5mm}
\noindent\small\verb!cpdf -list-images[-json] in.pdf [<range>]!
\vspace{1.5mm}
\noindent\small\verb!cpdf -image-resolution[-json] <minimum resolution> in.pdf [<range>]!
\vspace{1.5mm}
\noindent\small\verb!cpdf -list-images-used[-json] in.pdf [<range>]!
\end{framed}
\section{Extracting images}
@ -3634,22 +3642,60 @@ The output specifier, e.g \verb!-o output/%%%! gives the number format for numbe
\noindent The \texttt{output} directory must already exist. The \texttt{-dedup} option deduplicates images entirely; the \texttt{-dedup-perpage} option only per page.
\section{Detecting Low-resolution Images}\label{imageres}
\section{Listing images}
The \texttt{-list-images} operation lists all images in the file:
\begin{framed}
{\small\begin{verbatim}6, 1, /Z_Im0, 3300, 2550, 13432, 1, /DeviceGray, /CCITTFaxDecode
9, 2 13 14 15, /Z_Im0, 3376, 2649, 37972, 1, /DeviceGray, /CCITTFaxDecode\end{verbatim}}
\end{framed}
\noindent The fields are \textit{object number, page numbers, image name, width, height, size in bytes, bits per pixel, colour space, filter (compression method)}. With \texttt{-list-images-json}, the same information is available in JSON format:
\begin{framed}
{\small\begin{verbatim}[
{
"Object": 6,
"Pages": [ 1 ],
"Name": "/Z_Im0",
"Width": 3300,
"Height": 2550,
"Bytes": 13432,
"BitsPerComponent": 1,
"Colourspace": "/DeviceGray",
"Filter": "/CCITTFaxDecode"
},
{
"Object": 9,
"Pages": [ 2, 13, 14, 15 ],
"Name": "/Z_Im0",
"Width": 3376,
"Height": 2649,
"Bytes": 37972,
"BitsPerComponent": 1,
"Colourspace": "/DeviceGray",
"Filter": "/CCITTFaxDecode"
}
]\end{verbatim}}
\end{framed}
\section{Listing images at point of use}\label{imageres}
To list all images in the given range of pages which fall below a given resolution (in dots-per-inch), use the \verb!-image-resolution! function:
\begin{framed}
\noindent\small\verb@cpdf -image-resolution 300 in.pdf [<range>]@
\end{framed}
\begin{framed}
{\small\begin{verbatim}2, /Im5, 531, 684, 149.935297, 150.138267
2, /Im6, 184, 164, 149.999988, 150.458710
2, /Im7, 171, 156, 149.999996, 150.579145
2, /Im9, 65, 91, 149.999986, 151.071856
2, /Im10, 94, 60, 149.999990, 152.284285
2, /Im15, 184, 139, 149.960011, 150.672060
4, /Im29, 53, 48, 149.970749, 151.616446\end{verbatim}}
{\small\begin{verbatim}2, /Im5, 531, 684, 149.935297, 150.138267, 31
2, /Im6, 184, 164, 149.999988, 150.458710, 39
2, /Im7, 171, 156, 149.999996, 150.579145, 40
2, /Im9, 65, 91, 149.999986, 151.071856, 57
2, /Im10, 94, 60, 149.999990, 152.284285, 59
2, /Im15, 184, 139, 149.960011, 150.672060, 91
4, /Im29, 53, 48, 149.970749, 151.616446, 93\end{verbatim}}
\end{framed}
\noindent The format is \textit{page number, image name, x pixels, y pixels, x resolution, y resolution}. The resolutions refer to the image's effective resolution at point of use (taking account
\noindent The format is \textit{page number, image name, x pixels, y pixels, x resolution, y resolution, object number}. The resolutions refer to the image's effective resolution at point of use (taking account
of scaling, rotation etc).
The information is also available in JSON format:
@ -3678,6 +3724,8 @@ The information is also available in JSON format:
\end{verbatim}}
\end{framed}
\noindent To list all images regardless of resolution, use \texttt{-list-images-used} or \texttt{-list-images-used-json} instead.
\section{Removing an Image}
To remove a particular image, find its name using \texttt{-image-resolution} with a sufficiently high resolution (so as to list all images), and then apply the \texttt{-draft} and \texttt{-draft-remove-only} operations from Section \ref{draft}.