From 24fdbd453574691cfd285afcf346e07b61dab0a9 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Sat, 23 Dec 2023 15:29:13 +0000 Subject: [PATCH] Work around jbig2enc bug --- cpdfimage.ml | 1 + 1 file changed, 1 insertion(+) diff --git a/cpdfimage.ml b/cpdfimage.ml index 6605703..e2484dc 100644 --- a/cpdfimage.ml +++ b/cpdfimage.ml @@ -595,6 +595,7 @@ let recompress_1bpp_jbig2_lossless ~path_to_jbig2enc pdf s dict reference = match Pdf.lookup_direct pdf "/Filter" (fst !reference) with Some _ -> () | None -> let w = match Pdf.lookup_direct pdf "/Width" dict with Some (Pdf.Integer i) -> i | _ -> error "bad width" in let h = match Pdf.lookup_direct pdf "/Height" dict with Some (Pdf.Integer i) -> i | _ -> error "bad height" in + if w < 5 || h < 5 then () else (* jbig2enc fails on tiny images *) let out = Filename.temp_file "cpdf" "convertin" ^ ".pnm" in let out2 = Filename.temp_file "cpdf" "convertout" ^ ".jbig2" in let fh = open_out_bin out in