Beginning target_dpi implementation

This commit is contained in:
John Whitington 2024-02-01 14:29:41 +00:00
parent 319fb8e225
commit 58e18a6caa
1 changed files with 11 additions and 1 deletions

View File

@ -660,6 +660,12 @@ let lossless_resample pdf ~pixel_threshold ~length_threshold ~factor ~interpolat
remove out3*)
with _ -> () (* FIXME Remove *)
let lossless_resample_target_dpi objnum pdf ~pixel_threshold ~length_threshold ~target_dpi_info ~interpolate ~path_to_convert s dict reference =
let factor =
1
in
lossless_resample pdf ~pixel_threshold ~length_threshold ~factor ~interpolate ~path_to_convert s dict reference
let recompress_1bpp_jbig2_lossless ~pixel_threshold ~length_threshold ~path_to_jbig2enc pdf s dict reference =
let old = !reference in
let restore () = reference := old in
@ -825,6 +831,7 @@ let process
begin match onebppmethod with Some "JBIG2Lossy" -> preprocess_jbig2_lossy ~path_to_jbig2enc ~jbig2_lossy_threshold ~dpi_threshold ~length_threshold ~pixel_threshold inrange highdpi pdf | _ -> () end;
let nobjects = Pdf.objcard pdf in
let ndone = ref 0 in
let target_dpi_info = if factor < 0 then [] else [] in
let process_obj objnum s =
match s with
| Pdf.Stream ({contents = dict, _} as reference) ->
@ -868,6 +875,9 @@ let process
if factor < 101 then
begin
if !debug_image_processing then Printf.printf "(%i/%i) object %i (lossless)... %!" !ndone nobjects objnum;
if factor < 0 then
lossless_resample_target_dpi objnum pdf ~pixel_threshold ~length_threshold ~target_dpi_info ~interpolate ~path_to_convert s dict reference
else
lossless_resample pdf ~pixel_threshold ~length_threshold ~factor ~interpolate ~path_to_convert s dict reference
end
end