Scaffolding for dpi threshold

This commit is contained in:
John Whitington 2024-01-04 11:43:27 +00:00
parent f775ae304b
commit 3a39b5497a
3 changed files with 14 additions and 4 deletions

View File

@ -529,6 +529,7 @@ type args =
mutable pixel_threshold : int;
mutable length_threshold : int;
mutable percentage_threshold : int;
mutable dpi_threshold : int;
mutable resample_factor : int;
mutable resample_interpolate : bool}
@ -660,6 +661,7 @@ let args =
pixel_threshold = 25;
length_threshold = 100;
percentage_threshold = 99;
dpi_threshold = 0;
resample_factor = 101;
resample_interpolate = false}
@ -777,6 +779,7 @@ let reset_arguments () =
args.pixel_threshold <- 25;
args.length_threshold <- 100;
args.percentage_threshold <- 99;
args.dpi_threshold <- 0;
args.resample_factor <- 101;
args.resample_interpolate <- false;
clear Cpdfdrawcontrol.fontpack_initialised
@ -1962,6 +1965,9 @@ let setlengththreshold i =
let setpercentagethreshold i =
args.percentage_threshold <- i
let setdpithreshold i =
args.dpi_threshold <- i
let setlosslessresample i =
args.resample_factor <- i
@ -2772,6 +2778,9 @@ and specs =
("-percentage-threshold",
Arg.Int setpercentagethreshold,
" Only substitute lossy image when smaller than this");
("-dpi-threshold",
Arg.Int setdpithreshold,
" Only process image when always higher than this dpi");
("-lossless-resample",
Arg.Int setlosslessresample,
" Resample lossless images to given part of original");
@ -4518,7 +4527,7 @@ let go () =
Cpdfimage.process
~q:args.jpegquality ~qlossless:args.jpegqualitylossless ~onebppmethod:args.onebppmethod
~length_threshold:args.length_threshold ~percentage_threshold:args.percentage_threshold ~pixel_threshold:args.pixel_threshold
~factor:args.resample_factor ~interpolate:args.resample_interpolate
~dpi_threshold:args.dpi_threshold ~factor:args.resample_factor ~interpolate:args.resample_interpolate
~path_to_jbig2enc:args.path_to_jbig2enc ~path_to_convert:args.path_to_convert range pdf;
write_pdf false pdf

View File

@ -718,8 +718,8 @@ let recompress_1bpp_jbig2_lossless ~pixel_threshold ~length_threshold ~path_to_j
- Downsample colours as well as pixels
- JBIG2 with refinement coding for multipage lossless? *)
let process
?q ?qlossless ?onebppmethod ~length_threshold ~percentage_threshold ~pixel_threshold ~factor ~interpolate
~path_to_jbig2enc ~path_to_convert range pdf
?q ?qlossless ?onebppmethod ~length_threshold ~percentage_threshold ~pixel_threshold ~dpi_threshold
~factor ~interpolate ~path_to_jbig2enc ~path_to_convert range pdf
=
let inrange =
match images pdf range with

View File

@ -14,10 +14,11 @@ val image_resolution : Pdf.t -> int list -> float -> (int * string * int * int *
(** List images in JSON format *)
val images : Pdf.t -> int list -> Cpdfyojson.Safe.t
(** Reprocess images *)
val process :
?q:int -> ?qlossless:int -> ?onebppmethod:string ->
length_threshold:int -> percentage_threshold:int -> pixel_threshold:int ->
factor:int -> interpolate:bool ->
dpi_threshold:int -> factor:int -> interpolate:bool ->
path_to_jbig2enc:string -> path_to_convert:string -> int list -> Pdf.t -> unit
(**/**)