Resolve interface for factor/dpi_target

This commit is contained in:
John Whitington 2024-02-01 13:29:20 +00:00
parent 7eee1bf694
commit 319fb8e225
3 changed files with 11 additions and 14 deletions

View File

@ -537,7 +537,6 @@ type args =
mutable length_threshold : int;
mutable percentage_threshold : int;
mutable dpi_threshold : int;
mutable dpi_target : int;
mutable resample_factor : int;
mutable resample_interpolate : bool;
mutable jbig2_lossy_threshold : float;
@ -673,7 +672,6 @@ let args =
length_threshold = 100;
percentage_threshold = 99;
dpi_threshold = 0;
dpi_target = 0;
resample_factor = 101;
resample_interpolate = false;
jbig2_lossy_threshold = 0.85;
@ -795,7 +793,6 @@ let reset_arguments () =
args.length_threshold <- 100;
args.percentage_threshold <- 99;
args.dpi_threshold <- 0;
args.dpi_target <- 0;
args.resample_factor <- 101;
args.resample_interpolate <- false;
args.jbig2_lossy_threshold <- 0.85;
@ -1839,12 +1836,12 @@ let setpercentagethreshold i =
let setdpithreshold i =
args.dpi_threshold <- i
let setdpitarget i =
args.dpi_target <- i
let setlosslessresample i =
args.resample_factor <- i
let setlosslessresampledpi i =
args.resample_factor <- -i
let setresampleinterpolate () =
args.resample_interpolate <- true
@ -2680,12 +2677,12 @@ and specs =
("-lossless-resample",
Arg.Int setlosslessresample,
" Resample lossless images to given part of original");
("-lossless-resample",
Arg.Int setlosslessresampledpi,
" Resample lossless images to given DPI");
("-resample-interpolate",
Arg.Unit setresampleinterpolate,
" Interpolate when resampling");
("-dpi-target",
Arg.Int setdpitarget,
" Resample to this dpi when using -lossless-resample");
("-squeeze",
Arg.Unit setsqueeze,
" Squeeze");
@ -4455,7 +4452,7 @@ let go () =
Cpdfimage.process
~q:args.jpegquality ~qlossless:args.jpegqualitylossless ~onebppmethod:args.onebppmethod ~jbig2_lossy_threshold:args.jbig2_lossy_threshold
~length_threshold:args.length_threshold ~percentage_threshold:args.percentage_threshold ~pixel_threshold:args.pixel_threshold
~dpi_threshold:args.dpi_threshold ~dpi_target:args.dpi_target ~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
| Some (ExtractStream i) ->

View File

@ -619,7 +619,7 @@ let lossless_to_jpeg pdf ~pixel_threshold ~length_threshold ~percentage_threshol
remove out;
remove out2
let lossless_resample pdf ~pixel_threshold ~length_threshold ~dpi_target ~factor ~interpolate ~path_to_convert s dict reference =
let lossless_resample pdf ~pixel_threshold ~length_threshold ~factor ~interpolate ~path_to_convert s dict reference =
match lossless_out pdf ~pixel_threshold ~length_threshold ".png" s dict reference with
| None -> ()
| Some (_, _, _, 4, _, _) -> Printf.printf "lossless resampling for CMYK not supported yet\n%!"
@ -800,7 +800,7 @@ let preprocess_jbig2_lossy ~path_to_jbig2enc ~jbig2_lossy_threshold ~length_thre
let process
?q ?qlossless ?onebppmethod ~jbig2_lossy_threshold ~length_threshold ~percentage_threshold ~pixel_threshold ~dpi_threshold
~dpi_target ~factor ~interpolate ~path_to_jbig2enc ~path_to_convert range pdf
~factor ~interpolate ~path_to_jbig2enc ~path_to_convert range pdf
=
let inrange =
match images pdf range with
@ -868,7 +868,7 @@ let process
if factor < 101 then
begin
if !debug_image_processing then Printf.printf "(%i/%i) object %i (lossless)... %!" !ndone nobjects objnum;
lossless_resample pdf ~pixel_threshold ~length_threshold ~dpi_target ~factor ~interpolate ~path_to_convert s dict reference
lossless_resample pdf ~pixel_threshold ~length_threshold ~factor ~interpolate ~path_to_convert s dict reference
end
end
| None -> ()

View File

@ -18,7 +18,7 @@ val images : Pdf.t -> int list -> Cpdfyojson.Safe.t
val process :
?q:int -> ?qlossless:int -> ?onebppmethod:string -> jbig2_lossy_threshold:float ->
length_threshold:int -> percentage_threshold:int -> pixel_threshold:int ->
dpi_threshold:int -> dpi_target: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
(**/**)