Scaffolding for -list-images

This commit is contained in:
John Whitington 2023-11-13 17:55:59 +00:00
parent 33c690343c
commit 53e3d92a81
4 changed files with 14 additions and 3 deletions

View File

@ -7,13 +7,14 @@ o Spray splits a file to multiple outputs by alternating pages
o List document and page info in JSON format
o List page labels in JSON format
o List fonts in JSON format
o Identify PDF/A, PDF/X, PDF/E, PDF/VT, PDF/UA
o Identify PDF/A, PDF/X, PDF/E, PDF/VT, PDF/UA in -info
o Extract font files from a document
o List images on a page with -list-images[-json]
Extended features:
o -list-images-used[-json] extends -image-resolution
o Use -raw with -extract-images to get PNMs
Fixes:

View File

@ -4177,8 +4177,13 @@ let go () =
Printf.printf "%i, %s, %i, %i, %f, %f\n" pagenum xobject w h wdpi hdpi)
images
| Some ListImages ->
(* FIXME Implement ListImages *)
()
let pdf = get_single_pdf args.op true in
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
let json = Cpdfimage.images pdf range in
if args.format_json then
flprint (Cpdfyojson.Safe.pretty_to_string json)
else
flprint "old fashioned output\n"
| Some MissingFonts ->
let pdf = get_single_pdf args.op true in
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in

View File

@ -272,6 +272,8 @@ let image_resolution pdf range dpi =
image_resolution pdf range dpi;
rev !image_results
let images pdf range = `Null
let obj_of_jpeg_data data =
let w, h = Cpdfjpeg.jpeg_dimensions data in
let d =

View File

@ -8,6 +8,9 @@ val extract_images : ?raw:bool -> ?path_to_p2p:string ->
(** Report image resolutions. *)
val image_resolution : Pdf.t -> int list -> float -> (int * string * int * int * float * float) list
(** List images in JSON format *)
val images : Pdf.t -> int list -> Cpdfyojson.Safe.t
(**/**)
val image_of_input : (Pdfio.bytes -> Pdf.pdfobject) -> Pdfio.input -> Pdf.t
val obj_of_jpeg_data : Pdfio.bytes -> Pdf.pdfobject