From adeb7c6c33ceba7ab8af9fcf5793518a70ecc369 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Sat, 16 Dec 2023 20:18:06 +0000 Subject: [PATCH] Use new CamlPDF option to avoid pointless compression --- Changes | 1 + cpdfdraft.ml | 2 +- cpdfsqueeze.ml | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Changes b/Changes index d153d77..dea0e12 100644 --- a/Changes +++ b/Changes @@ -25,6 +25,7 @@ Fixes: o Added opam file in-source o Fixed -set-annotations with page links o Allow Exif JPEGs as well as JFIF ones in -jpeg and -draw-jpeg +o Only compress a stream if it actually makes it smaller 2.6.1 (September 2023) diff --git a/cpdfdraft.ml b/cpdfdraft.ml index 3fe8ffd..b448976 100644 --- a/cpdfdraft.ml +++ b/cpdfdraft.ml @@ -138,7 +138,7 @@ and remove_images_page onlyremove boxes pdf page = {page with Pdfpage.content = (let stream = Pdfops.stream_of_ops content' in - Pdfcodec.encode_pdfstream pdf Pdfcodec.Flate stream; + Pdfcodec.encode_pdfstream ~only_if_smaller:true pdf Pdfcodec.Flate stream; [stream]); Pdfpage.resources = resources'}, pdf diff --git a/cpdfsqueeze.ml b/cpdfsqueeze.ml index 06ab481..8e1de1a 100644 --- a/cpdfsqueeze.ml +++ b/cpdfsqueeze.ml @@ -21,7 +21,7 @@ let recompress_stream pdf = function with | _, Some (Pdf.Name "/Metadata") -> () | (None | Some (Pdf.Array [])), _ -> - Pdfcodec.encode_pdfstream pdf Pdfcodec.Flate stream + Pdfcodec.encode_pdfstream ~only_if_smaller:true pdf Pdfcodec.Flate stream | _ -> () end | _ -> assert false