diff --git a/cpdfimage.ml b/cpdfimage.ml index 7f83782..96b5db6 100644 --- a/cpdfimage.ml +++ b/cpdfimage.ml @@ -468,30 +468,26 @@ let process pdf ~q ~qlossless ~path_to_convert = let out = Filename.temp_file "cpdf" "convertin" ^ ".jpg" in let out2 = Filename.temp_file "cpdf" "convertout" ^ ".jpg" in let fh = open_out_bin out in - (* 1. Write data to temp file *) let size = begin match s with Pdf.Stream {contents = _, Pdf.Got d} -> Pdfio.bytes_to_output_channel fh d; bytes_size d | _ -> 0 end in close_out fh; - (* 2. Process with convert. *) let retcode = let command = (Filename.quote_command path_to_convert [out; "-quality"; string_of_int q ^ "%"; out2]) in - Printf.printf "%S\n" command; + (*Printf.printf "%S\n" command;*) Sys.command command in if retcode = 0 then begin - (* 3. If return code 0, and output file produced, read it in *) let result = open_in_bin out2 in let newsize = in_channel_length result in if newsize < size then - (* 4. Replace the data, but only if it was smaller *) + (*Printf.printf "%i -> %i\n" size newsize;*) reference := Pdf.add_dict_entry dict "/Length" (Pdf.Integer newsize), Pdf.Got (Pdfio.bytes_of_input_channel result) end; - (* 5. Clean up *) Sys.remove out; Sys.remove out2 | _ -> ()