diff --git a/cpdfcommand.ml b/cpdfcommand.ml index 5ad288e..b4eaeaa 100644 --- a/cpdfcommand.ml +++ b/cpdfcommand.ml @@ -542,6 +542,8 @@ type args = mutable no_warn_rotate : bool; mutable jpegquality : float; mutable jpegqualitylossless : float; + mutable jpegtojpegscale : float; + mutable jpegtojpegdpi : float; mutable onebppmethod : string; mutable pixel_threshold : int; mutable length_threshold : int; @@ -681,6 +683,8 @@ let args = no_warn_rotate = false; jpegquality = 100.; jpegqualitylossless = 101.; + jpegtojpegscale = 1.; + jpegtojpegdpi = 0.; onebppmethod = ""; pixel_threshold = 25; length_threshold = 100; @@ -1894,6 +1898,12 @@ let setjpegquality q = let setjpegqualitylossless q = args.jpegqualitylossless <- q +let setjpegtojpegscale q = + args.jpegtojpegscale <- q + +let setjpegtojpegdpi q = + args.jpegtojpegdpi <- q + let set1bppmethod m = args.onebppmethod <- m @@ -2765,6 +2775,12 @@ let specs = ("-jpeg-to-jpeg", Arg.Float setjpegquality, " Set JPEG quality for existing JPEGs"); + ("-jpeg-to-jpeg-scale", + Arg.Float setjpegtojpegscale, + " Set the percentage scale for -jpeg-to-jpeg"); + ("-jpeg-to-jpeg-dpi", + Arg.Float setjpegtojpegdpi, + " Set the DPI target for -jpeg-to-jpeg"); ("-lossless-to-jpeg", Arg.Float setjpegqualitylossless, " Set JPEG quality for existing lossless images"); @@ -4647,6 +4663,7 @@ let go () = ~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 ~factor:args.resample_factor ~interpolate:args.resample_interpolate + ~jpeg_to_jpeg_scale:args.jpegtojpegscale ~jpeg_to_jpeg_dpi:args.jpegtojpegdpi ~path_to_jbig2enc:args.path_to_jbig2enc ~path_to_convert:args.path_to_im range pdf; write_pdf false pdf | Some (ExtractStream s) -> diff --git a/cpdfimage.ml b/cpdfimage.ml index db6530b..9fc899c 100644 --- a/cpdfimage.ml +++ b/cpdfimage.ml @@ -562,7 +562,7 @@ let image_of_input ?subformat ?title ~process_struct_tree fobj i = let pdf, pageroot = Pdfpage.add_pagetree [page] pdf in Pdfpage.add_root pageroot [] pdf -let jpeg_to_jpeg pdf ~pixel_threshold ~length_threshold ~percentage_threshold ~q ~path_to_convert s dict reference = +let jpeg_to_jpeg pdf ~pixel_threshold ~length_threshold ~percentage_threshold ~jpeg_to_jpeg_scale ~jpeg_to_jpeg_dpi ~q ~path_to_convert s dict reference = if q < 0. || q > 100. then error "Out of range quality"; complain_convert path_to_convert; let w = match Pdf.lookup_direct pdf "/Width" dict with Some (Pdf.Integer i) -> i | _ -> error "bad width" in @@ -934,7 +934,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 - ~factor ~interpolate ~path_to_jbig2enc ~path_to_convert range pdf + ~factor ~interpolate ~jpeg_to_jpeg_scale ~jpeg_to_jpeg_dpi ~path_to_jbig2enc ~path_to_convert range pdf = let inrange = match images pdf range with @@ -975,7 +975,7 @@ let process if q < 100. then begin if !debug_image_processing then Printf.printf "(%i/%i) Object %i (JPEG)... %!" !ndone nobjects objnum; - jpeg_to_jpeg pdf ~pixel_threshold ~length_threshold ~percentage_threshold ~q ~path_to_convert s dict reference + jpeg_to_jpeg pdf ~pixel_threshold ~length_threshold ~percentage_threshold ~jpeg_to_jpeg_scale ~jpeg_to_jpeg_dpi ~q ~path_to_convert s dict reference end | Some (Pdf.Name "/Image"), _, Some (Pdf.Integer 1), _ | Some (Pdf.Name "/Image"), _, _, Some (Pdf.Boolean true) -> diff --git a/cpdfimage.mli b/cpdfimage.mli index aa3f0f8..028ba99 100644 --- a/cpdfimage.mli +++ b/cpdfimage.mli @@ -22,6 +22,7 @@ val process : q:float -> qlossless:float -> onebppmethod:string -> jbig2_lossy_threshold:float -> length_threshold:int -> percentage_threshold:float -> pixel_threshold:int -> dpi_threshold:float -> factor:float -> interpolate:bool -> + jpeg_to_jpeg_scale:float -> jpeg_to_jpeg_dpi:float -> path_to_jbig2enc:string -> path_to_convert:string -> int list -> Pdf.t -> unit (**/**)