more
This commit is contained in:
parent
a8603881a8
commit
f775ae304b
|
@ -4496,7 +4496,6 @@ let go () =
|
|||
| Some Draw ->
|
||||
let pdf = get_single_pdf args.op false in
|
||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||
|
||||
let ops = match !Cpdfdrawcontrol.drawops with [("_MAIN", ops)] -> rev ops | _ -> error "not enough -end-xobj or -et" in
|
||||
write_pdf
|
||||
false
|
||||
|
@ -4515,11 +4514,12 @@ let go () =
|
|||
write_pdf false (Cpdfchop.chop ~x ~y ~columns:args.impose_columns ~btt:args.impose_btt ~rtl:args.impose_rtl pdf range)
|
||||
| Some ProcessImages ->
|
||||
let pdf = get_single_pdf args.op false in
|
||||
let range = parse_pagespec_allow_empty pdf (get_pagespec ()) in
|
||||
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
|
||||
~path_to_jbig2enc:args.path_to_jbig2enc ~path_to_convert:args.path_to_convert pdf;
|
||||
~path_to_jbig2enc:args.path_to_jbig2enc ~path_to_convert:args.path_to_convert range pdf;
|
||||
write_pdf false pdf
|
||||
|
||||
(* Advise the user if a combination of command line flags makes little sense,
|
||||
|
|
16
cpdfimage.ml
16
cpdfimage.ml
|
@ -713,20 +713,26 @@ let recompress_1bpp_jbig2_lossless ~pixel_threshold ~length_threshold ~path_to_j
|
|||
remove out2
|
||||
end
|
||||
|
||||
(* JPEG to JPEG: RGB and CMYK JPEGS *)
|
||||
(* Lossless to JPEG: 8bpp Grey, 8bpp RGB, 8bpp CMYK including separation and ICCBased colourspaces *)
|
||||
(* 1 bit: anything to JBIG2 lossless (no globals) *)
|
||||
(* TODO:
|
||||
- 2bpp, 4bpp, 16bpp images.
|
||||
- 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 pdf
|
||||
~path_to_jbig2enc ~path_to_convert range pdf
|
||||
=
|
||||
let inrange =
|
||||
match images pdf range with
|
||||
| `List l -> hashset_of_list (map (function `Assoc (("Object", `Int i)::_) -> i | _ -> assert false) l)
|
||||
| _ -> assert false
|
||||
in
|
||||
let nobjects = Pdf.objcard pdf in
|
||||
let ndone = ref 0 in
|
||||
let process_obj objnum s =
|
||||
match s with
|
||||
| Pdf.Stream ({contents = dict, _} as reference) ->
|
||||
ndone += 1;
|
||||
begin match
|
||||
if Hashtbl.mem inrange objnum then begin match
|
||||
Pdf.lookup_direct pdf "/Subtype" dict,
|
||||
Pdf.lookup_direct pdf "/Filter" dict,
|
||||
Pdf.lookup_direct pdf "/BitsPerComponent" dict,
|
||||
|
|
|
@ -18,7 +18,7 @@ val process :
|
|||
?q:int -> ?qlossless:int -> ?onebppmethod:string ->
|
||||
length_threshold:int -> percentage_threshold:int -> pixel_threshold:int ->
|
||||
factor:int -> interpolate:bool ->
|
||||
path_to_jbig2enc:string -> path_to_convert:string -> Pdf.t -> unit
|
||||
path_to_jbig2enc:string -> path_to_convert:string -> int list -> Pdf.t -> unit
|
||||
|
||||
(**/**)
|
||||
val image_of_input : (unit -> Pdfio.bytes -> Pdf.pdfobject * (int * Pdf.pdfobject) list) -> Pdfio.input -> Pdf.t
|
||||
|
|
Loading…
Reference in New Issue