mirror of
https://github.com/johnwhitington/cpdf-source.git
synced 2025-01-03 12:29:19 +01:00
Plumbing for -jpeg-to-jpeg-scale, -jpeg-to-jpeg-dpi
This commit is contained in:
parent
6724d48fd6
commit
10d772fc36
@ -542,6 +542,8 @@ type args =
|
|||||||
mutable no_warn_rotate : bool;
|
mutable no_warn_rotate : bool;
|
||||||
mutable jpegquality : float;
|
mutable jpegquality : float;
|
||||||
mutable jpegqualitylossless : float;
|
mutable jpegqualitylossless : float;
|
||||||
|
mutable jpegtojpegscale : float;
|
||||||
|
mutable jpegtojpegdpi : float;
|
||||||
mutable onebppmethod : string;
|
mutable onebppmethod : string;
|
||||||
mutable pixel_threshold : int;
|
mutable pixel_threshold : int;
|
||||||
mutable length_threshold : int;
|
mutable length_threshold : int;
|
||||||
@ -681,6 +683,8 @@ let args =
|
|||||||
no_warn_rotate = false;
|
no_warn_rotate = false;
|
||||||
jpegquality = 100.;
|
jpegquality = 100.;
|
||||||
jpegqualitylossless = 101.;
|
jpegqualitylossless = 101.;
|
||||||
|
jpegtojpegscale = 1.;
|
||||||
|
jpegtojpegdpi = 0.;
|
||||||
onebppmethod = "";
|
onebppmethod = "";
|
||||||
pixel_threshold = 25;
|
pixel_threshold = 25;
|
||||||
length_threshold = 100;
|
length_threshold = 100;
|
||||||
@ -1894,6 +1898,12 @@ let setjpegquality q =
|
|||||||
let setjpegqualitylossless q =
|
let setjpegqualitylossless q =
|
||||||
args.jpegqualitylossless <- q
|
args.jpegqualitylossless <- q
|
||||||
|
|
||||||
|
let setjpegtojpegscale q =
|
||||||
|
args.jpegtojpegscale <- q
|
||||||
|
|
||||||
|
let setjpegtojpegdpi q =
|
||||||
|
args.jpegtojpegdpi <- q
|
||||||
|
|
||||||
let set1bppmethod m =
|
let set1bppmethod m =
|
||||||
args.onebppmethod <- m
|
args.onebppmethod <- m
|
||||||
|
|
||||||
@ -2765,6 +2775,12 @@ let specs =
|
|||||||
("-jpeg-to-jpeg",
|
("-jpeg-to-jpeg",
|
||||||
Arg.Float setjpegquality,
|
Arg.Float setjpegquality,
|
||||||
" Set JPEG quality for existing JPEGs");
|
" 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",
|
("-lossless-to-jpeg",
|
||||||
Arg.Float setjpegqualitylossless,
|
Arg.Float setjpegqualitylossless,
|
||||||
" Set JPEG quality for existing lossless images");
|
" 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
|
~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
|
~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
|
~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;
|
~path_to_jbig2enc:args.path_to_jbig2enc ~path_to_convert:args.path_to_im range pdf;
|
||||||
write_pdf false pdf
|
write_pdf false pdf
|
||||||
| Some (ExtractStream s) ->
|
| Some (ExtractStream s) ->
|
||||||
|
@ -562,7 +562,7 @@ let image_of_input ?subformat ?title ~process_struct_tree fobj i =
|
|||||||
let pdf, pageroot = Pdfpage.add_pagetree [page] pdf in
|
let pdf, pageroot = Pdfpage.add_pagetree [page] pdf in
|
||||||
Pdfpage.add_root pageroot [] pdf
|
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";
|
if q < 0. || q > 100. then error "Out of range quality";
|
||||||
complain_convert path_to_convert;
|
complain_convert path_to_convert;
|
||||||
let w = match Pdf.lookup_direct pdf "/Width" dict with Some (Pdf.Integer i) -> i | _ -> error "bad width" in
|
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
|
let process
|
||||||
~q ~qlossless ~onebppmethod ~jbig2_lossy_threshold ~length_threshold ~percentage_threshold ~pixel_threshold ~dpi_threshold
|
~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 =
|
let inrange =
|
||||||
match images pdf range with
|
match images pdf range with
|
||||||
@ -975,7 +975,7 @@ let process
|
|||||||
if q < 100. then
|
if q < 100. then
|
||||||
begin
|
begin
|
||||||
if !debug_image_processing then Printf.printf "(%i/%i) Object %i (JPEG)... %!" !ndone nobjects objnum;
|
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
|
end
|
||||||
| Some (Pdf.Name "/Image"), _, Some (Pdf.Integer 1), _
|
| Some (Pdf.Name "/Image"), _, Some (Pdf.Integer 1), _
|
||||||
| Some (Pdf.Name "/Image"), _, _, Some (Pdf.Boolean true) ->
|
| Some (Pdf.Name "/Image"), _, _, Some (Pdf.Boolean true) ->
|
||||||
|
@ -22,6 +22,7 @@ val process :
|
|||||||
q:float -> qlossless:float -> onebppmethod:string -> jbig2_lossy_threshold:float ->
|
q:float -> qlossless:float -> onebppmethod:string -> jbig2_lossy_threshold:float ->
|
||||||
length_threshold:int -> percentage_threshold:float -> pixel_threshold:int ->
|
length_threshold:int -> percentage_threshold:float -> pixel_threshold:int ->
|
||||||
dpi_threshold:float -> factor:float -> interpolate:bool ->
|
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
|
path_to_jbig2enc:string -> path_to_convert:string -> int list -> Pdf.t -> unit
|
||||||
|
|
||||||
(**/**)
|
(**/**)
|
||||||
|
Loading…
Reference in New Issue
Block a user