diff --git a/cpdfimage.ml b/cpdfimage.ml index 173d57d..8add670 100644 --- a/cpdfimage.ml +++ b/cpdfimage.ml @@ -617,17 +617,20 @@ let lossless_to_jpeg pdf ~pixel_threshold ~length_threshold ~percentage_threshol remove out; remove out2 +(* FIXME Need to specify exactly where this works, how to process with convert for each etc. *) let lossless_resample pdf ~pixel_threshold ~length_threshold ~percentage_threshold ~factor ~interpolate ~path_to_convert s dict reference = match lossless_out pdf ~pixel_threshold ~length_threshold ".png" s dict reference with None -> () | Some (out, out2, size, components, w, h) -> let retcode = + (* FIXME upscale required at all? *) let command = (Filename.quote_command path_to_convert ((if components = 4 then ["-depth"; "8"; "-size"; string_of_int w ^ "x" ^ string_of_int h] else []) @ (if components = 1 then ["-colorspace"; "Gray"] else if components = 3 then ["-colorspace"; "RGB"] else if components = 4 then ["-colorspace"; "CMYK"] else []) @ + ["-sample"; string_of_int factor ^ "%"] @ [out] @ - ["PNG24:" ^ out2])) + ["PNG24:" ^ out2])) (*FIXME do we need this anymore? *) in - Printf.printf "%S\n" command; Sys.command command + (*Printf.printf "%S\n" command;*) Sys.command command in if retcode = 0 then begin @@ -636,13 +639,12 @@ let lossless_resample pdf ~pixel_threshold ~length_threshold ~percentage_thresho if newsize < size then begin if !debug_image_processing then Printf.printf "lossless resample %i -> %i (%i%%)\n%!" size newsize (int_of_float (float newsize /. float size *. 100.)); - (* FIXME Load PNG data in, per existing code: add filter, predictor, length *) + (* FIXME Merge any extra dictionary entries from original on top of the one read back. *) + (* FIXME Check that we got back in what we expected? *) reference := - (Pdf.add_dict_entry - (Pdf.add_dict_entry dict "/Length" (Pdf.Integer newsize)) - "/Filter" - (Pdf.Name "/DCTDecode")), - Pdf.Got (Pdfio.bytes_of_input_channel result) + match fst (obj_of_png_data (Pdfio.bytes_of_input_channel result)) with + | Pdf.Stream s -> !s + | _ -> assert false end else begin