From 94cb707dd902ad6500bb5b7ee406eab1b58abc03 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Wed, 27 Dec 2023 20:01:06 +0000 Subject: [PATCH] Only do JPEGing then quality set < 100 --- cpdfimage.ml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cpdfimage.ml b/cpdfimage.ml index ec950cf..8004e91 100644 --- a/cpdfimage.ml +++ b/cpdfimage.ml @@ -647,18 +647,21 @@ let process with | Some (Pdf.Name "/Image"), Some (Pdf.Name "/DCTDecode" | Pdf.Array [Pdf.Name "/DCTDecode"]), _, _ -> begin match q with - | Some q -> jpeg_to_jpeg pdf ~pixel_threshold ~q ~path_to_convert s dict reference + | Some q -> + if q < 100 then jpeg_to_jpeg pdf ~pixel_threshold ~q ~path_to_convert s dict reference | None -> () end | Some (Pdf.Name "/Image"), _, Some (Pdf.Integer 1), _ | Some (Pdf.Name "/Image"), _, _, Some (Pdf.Boolean true) -> begin match onebppmethod with - | Some "JBIG2" -> recompress_1bpp_jbig2_lossless ~pixel_threshold ~path_to_jbig2enc pdf s dict reference + | Some "JBIG2" -> + recompress_1bpp_jbig2_lossless ~pixel_threshold ~path_to_jbig2enc pdf s dict reference | _ -> () end | Some (Pdf.Name "/Image"), _, _, _ -> begin match qlossless with - | Some qlossless -> lossless_to_jpeg pdf ~pixel_threshold ~qlossless ~path_to_convert s dict reference + | Some qlossless -> + if qlossless < 100 then lossless_to_jpeg pdf ~pixel_threshold ~qlossless ~path_to_convert s dict reference | None -> () end | _ -> () (* not an image *)