more
This commit is contained in:
parent
0af6af567d
commit
51472da1fa
|
@ -3376,28 +3376,29 @@ let warn_prerotate range pdf =
|
||||||
let prerotate range pdf =
|
let prerotate range pdf =
|
||||||
Cpdfpage.upright ~fast:args.fast range pdf
|
Cpdfpage.upright ~fast:args.fast range pdf
|
||||||
|
|
||||||
let find_images pdf =
|
let find_composition pdf =
|
||||||
let imageobjs = ref [] in
|
let marked = null_hash () in
|
||||||
let size = ref 0 in
|
let images = ref 0 in
|
||||||
|
let content_streams = ref 0 in
|
||||||
Pdf.objiter
|
Pdf.objiter
|
||||||
(fun i obj ->
|
(fun i obj ->
|
||||||
|
match Hashtbl.find marked i with _ -> () | exception Not_found ->
|
||||||
match Pdf.lookup_direct pdf "/Subtype" obj with
|
match Pdf.lookup_direct pdf "/Subtype" obj with
|
||||||
| Some (Pdf.Name "/Image") ->
|
| Some (Pdf.Name "/Image") ->
|
||||||
size += String.length (Pdfwrite.string_of_pdf_including_data obj);
|
images += String.length (Pdfwrite.string_of_pdf_including_data obj);
|
||||||
imageobjs =| i
|
Hashtbl.add marked i ()
|
||||||
| _ -> ())
|
| _ -> ())
|
||||||
pdf;
|
pdf;
|
||||||
(!size, !imageobjs)
|
(!images, !content_streams)
|
||||||
|
|
||||||
(* First go: images, fonts, content streams, structure info, link annotations, embedded files *)
|
(* First go: images, fonts, content streams, structure info, link annotations, embedded files *)
|
||||||
let show_composition_json filesize pdf =
|
let show_composition_json filesize pdf =
|
||||||
let perc x = float_of_int x /. float_of_int filesize *. 100. in
|
let perc x = float_of_int x /. float_of_int filesize *. 100. in
|
||||||
let marked = null_hash () in
|
let images, content_streams = find_composition pdf in
|
||||||
let images, objs = find_images pdf in
|
let r = images + content_streams in
|
||||||
iter (fun o -> Hashtbl.add marked o ()) objs;
|
`List [`Tuple [`String "Images"; `Int images; `Float (perc images)];
|
||||||
let r = images in
|
`Tuple [`String "Content streams"; `Int content_streams; `Float (perc content_streams)];
|
||||||
`List [`Tuple [`String "Images"; `Int images; `Float (perc images)];
|
`Tuple [`String "Unclassified"; `Int (filesize - r); `Float (perc (filesize - r))]]
|
||||||
`Tuple [`String "Unclassified"; `Int (filesize - r); `Float (perc (filesize - r))]]
|
|
||||||
|
|
||||||
let show_composition filesize json pdf =
|
let show_composition filesize json pdf =
|
||||||
let module J = Cpdfyojson.Safe in
|
let module J = Cpdfyojson.Safe in
|
||||||
|
|
Loading…
Reference in New Issue