Plumbing for path_to_jbig2enc
This commit is contained in:
parent
57aabda801
commit
c0c72b8ec4
|
@ -469,6 +469,7 @@ type args =
|
||||||
mutable path_to_im : string;
|
mutable path_to_im : string;
|
||||||
mutable path_to_p2p : string;
|
mutable path_to_p2p : string;
|
||||||
mutable path_to_convert : string;
|
mutable path_to_convert : string;
|
||||||
|
mutable path_to_jbig2enc : string;
|
||||||
mutable frombox : string option;
|
mutable frombox : string option;
|
||||||
mutable tobox : string option;
|
mutable tobox : string option;
|
||||||
mutable mediabox_if_missing : bool;
|
mutable mediabox_if_missing : bool;
|
||||||
|
@ -589,10 +590,11 @@ let args =
|
||||||
dashrange = "all";
|
dashrange = "all";
|
||||||
outline = false;
|
outline = false;
|
||||||
linewidth = 1.0;
|
linewidth = 1.0;
|
||||||
path_to_ghostscript = "";
|
path_to_ghostscript = "gs";
|
||||||
path_to_im = "";
|
path_to_im = "magick";
|
||||||
path_to_p2p = "";
|
path_to_p2p = "pnm2png";
|
||||||
path_to_convert = "";
|
path_to_convert = "convert";
|
||||||
|
path_to_jbig2enc = "jbig2enc";
|
||||||
frombox = None;
|
frombox = None;
|
||||||
tobox = None;
|
tobox = None;
|
||||||
mediabox_if_missing = false;
|
mediabox_if_missing = false;
|
||||||
|
@ -1528,6 +1530,9 @@ let setimpath p =
|
||||||
let setconvertpath p =
|
let setconvertpath p =
|
||||||
args.path_to_convert <- p
|
args.path_to_convert <- p
|
||||||
|
|
||||||
|
let setjbig2encpath p =
|
||||||
|
args.path_to_jbig2enc <- p
|
||||||
|
|
||||||
let setp2ppath p =
|
let setp2ppath p =
|
||||||
args.path_to_p2p <- p
|
args.path_to_p2p <- p
|
||||||
|
|
||||||
|
@ -2710,6 +2715,9 @@ and specs =
|
||||||
("-convert",
|
("-convert",
|
||||||
Arg.String setconvertpath,
|
Arg.String setconvertpath,
|
||||||
" Path to convert executable");
|
" Path to convert executable");
|
||||||
|
("-jbig2enc",
|
||||||
|
Arg.String setjbig2encpath,
|
||||||
|
" Path to jbig2enc executable");
|
||||||
("-jpeg-to-jpeg",
|
("-jpeg-to-jpeg",
|
||||||
Arg.Int setjpegquality,
|
Arg.Int setjpegquality,
|
||||||
" Set JPEG quality for existing JPEGs");
|
" Set JPEG quality for existing JPEGs");
|
||||||
|
@ -4456,7 +4464,7 @@ let go () =
|
||||||
write_pdf false (Cpdfchop.chop ~x ~y ~columns:args.impose_columns ~btt:args.impose_btt ~rtl:args.impose_rtl pdf range)
|
write_pdf false (Cpdfchop.chop ~x ~y ~columns:args.impose_columns ~btt:args.impose_btt ~rtl:args.impose_rtl pdf range)
|
||||||
| Some ProcessImages ->
|
| Some ProcessImages ->
|
||||||
let pdf = get_single_pdf args.op false in
|
let pdf = get_single_pdf args.op false in
|
||||||
Cpdfimage.process pdf ~q:args.jpegquality ~qlossless:args.jpegqualitylossless ~onebppmethod:args.onebppmethod ~path_to_convert:args.path_to_convert;
|
Cpdfimage.process pdf ~q:args.jpegquality ~qlossless:args.jpegqualitylossless ~onebppmethod:args.onebppmethod ~path_to_jbig2enc:args.path_to_jbig2enc ~path_to_convert:args.path_to_convert;
|
||||||
write_pdf false pdf
|
write_pdf false pdf
|
||||||
|
|
||||||
(* Advise the user if a combination of command line flags makes little sense,
|
(* Advise the user if a combination of command line flags makes little sense,
|
||||||
|
|
12
cpdfimage.ml
12
cpdfimage.ml
|
@ -492,6 +492,7 @@ let image_of_input fobj i =
|
||||||
(* FIXME if lossy only 5% smaller, ignore? Set this parameter... *)
|
(* FIXME if lossy only 5% smaller, ignore? Set this parameter... *)
|
||||||
(* FIXME error handling for Sys.remove, others *)
|
(* FIXME error handling for Sys.remove, others *)
|
||||||
(* FIXME Use raw format for all, and make it fast *)
|
(* FIXME Use raw format for all, and make it fast *)
|
||||||
|
(* FIXME combine path_to_im / path_to_convert *)
|
||||||
let jpeg_to_jpeg pdf ~q ~path_to_convert s dict reference =
|
let jpeg_to_jpeg pdf ~q ~path_to_convert s dict reference =
|
||||||
Pdf.getstream s;
|
Pdf.getstream s;
|
||||||
let out = Filename.temp_file "cpdf" "convertin" ^ ".jpg" in
|
let out = Filename.temp_file "cpdf" "convertin" ^ ".jpg" in
|
||||||
|
@ -590,13 +591,18 @@ let lossless_to_jpeg pdf ~qlossless ~path_to_convert s dict reference =
|
||||||
print_string (Printf.sprintf "%s (%s) [%s]\n" colspace bpc filter);
|
print_string (Printf.sprintf "%s (%s) [%s]\n" colspace bpc filter);
|
||||||
() (* an image we cannot or do not handle *)
|
() (* an image we cannot or do not handle *)
|
||||||
|
|
||||||
let recompress_1bpp_jbig2_lossless pdf s dict reference =
|
let recompress_1bpp_jbig2_lossless ~path_to_jbig2enc pdf s dict reference =
|
||||||
|
(* 1. Decode it *)
|
||||||
|
(* 2. Check we are ok *)
|
||||||
|
(* 3. Call jbig2enc *)
|
||||||
|
(* 4. Read in result *)
|
||||||
|
(* 5. Set data and dictionary *)
|
||||||
()
|
()
|
||||||
|
|
||||||
(* JPEG to JPEG: RGB and CMYK JPEGS *)
|
(* JPEG to JPEG: RGB and CMYK JPEGS *)
|
||||||
(* Lossless to JPEG: 8bpp Grey, 8bpp RGB, 8bpp CMYK including separation add ICCBased colourspaces *)
|
(* Lossless to JPEG: 8bpp Grey, 8bpp RGB, 8bpp CMYK including separation add ICCBased colourspaces *)
|
||||||
(* 1 bit: anything to JBIG2 lossless (no globals) *)
|
(* 1 bit: anything to JBIG2 lossless (no globals) *)
|
||||||
let process ?q ?qlossless ?onebppmethod pdf ~path_to_convert =
|
let process ?q ?qlossless ?onebppmethod pdf ~path_to_jbig2enc ~path_to_convert =
|
||||||
let process_obj _ s =
|
let process_obj _ s =
|
||||||
match s with
|
match s with
|
||||||
| Pdf.Stream ({contents = dict, _} as reference) ->
|
| Pdf.Stream ({contents = dict, _} as reference) ->
|
||||||
|
@ -614,7 +620,7 @@ let process ?q ?qlossless ?onebppmethod pdf ~path_to_convert =
|
||||||
| 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) ->
|
||||||
begin match onebppmethod with
|
begin match onebppmethod with
|
||||||
| Some "JBIG2" -> recompress_1bpp_jbig2_lossless pdf s dict reference
|
| Some "JBIG2" -> recompress_1bpp_jbig2_lossless ~path_to_jbig2enc pdf s dict reference
|
||||||
| _ -> ()
|
| _ -> ()
|
||||||
end
|
end
|
||||||
| Some (Pdf.Name "/Image"), _, _, _ ->
|
| Some (Pdf.Name "/Image"), _, _, _ ->
|
||||||
|
|
|
@ -11,7 +11,7 @@ val image_resolution : Pdf.t -> int list -> float -> (int * string * int * int *
|
||||||
(** List images in JSON format *)
|
(** List images in JSON format *)
|
||||||
val images : Pdf.t -> int list -> Cpdfyojson.Safe.t
|
val images : Pdf.t -> int list -> Cpdfyojson.Safe.t
|
||||||
|
|
||||||
val process : ?q:int -> ?qlossless:int -> ?onebppmethod:string -> Pdf.t -> path_to_convert:string -> unit
|
val process : ?q:int -> ?qlossless:int -> ?onebppmethod:string -> Pdf.t -> path_to_jbig2enc:string -> path_to_convert:string -> unit
|
||||||
|
|
||||||
(**/**)
|
(**/**)
|
||||||
val image_of_input : (unit -> Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list) -> Pdfio.input -> Pdf.t
|
val image_of_input : (unit -> Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list) -> Pdfio.input -> Pdf.t
|
||||||
|
|
Loading…
Reference in New Issue