From 34bf294fac9abe7798b08199252b92542e8cadc2 Mon Sep 17 00:00:00 2001 From: John Whitington Date: Sat, 11 Jan 2025 10:24:39 +0800 Subject: [PATCH] Debug all CCITT by eliding checks --- cpdfimage.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cpdfimage.ml b/cpdfimage.ml index a063926..3482793 100644 --- a/cpdfimage.ml +++ b/cpdfimage.ml @@ -828,9 +828,9 @@ let recompress_1bpp_ccitt_lossless ~pixel_threshold ~length_threshold pdf s dict let restore () = reference := old in 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 * h < pixel_threshold then (if !debug_image_processing then Printf.printf "pixel threshold not met\n%!") else (* (but also, jbig2enc fails on tiny images) *) + (*if w * h < pixel_threshold then (if !debug_image_processing then Printf.printf "pixel threshold not met\n%!") else*) let size = match Pdf.lookup_direct pdf "/Length" dict with Some (Pdf.Integer i) -> i | _ -> 0 in - if size < length_threshold then (if !debug_image_processing then Printf.printf "length threshold not met\n%!") else + (*if size < length_threshold then (if !debug_image_processing then Printf.printf "length threshold not met\n%!") else*) begin Pdfcodec.decode_pdfstream_until_unknown pdf s; match Pdf.lookup_direct pdf "/Filter" (fst !reference) with @@ -841,7 +841,7 @@ let recompress_1bpp_ccitt_lossless ~pixel_threshold ~length_threshold pdf s dict let data = match s with Pdf.Stream {contents = _, Pdf.Got d} -> d | _ -> assert false in let compressed = Pdfcodec.encode_ccitt w data in let newsize = bytes_size compressed in - if newsize < size then + if true (*newsize < size*) then begin if !debug_image_processing then Printf.printf "1bpp to CCITT %i -> %i (%i%%)\n%!" size newsize (int_of_float (float newsize /. float size *. 100.)); reference := @@ -861,7 +861,7 @@ let recompress_1bpp_ccittg4_lossless ~pixel_threshold ~length_threshold pdf s di let restore () = reference := old in 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 * h < pixel_threshold then (if !debug_image_processing then Printf.printf "pixel threshold not met\n%!") else (* (but also, jbig2enc fails on tiny images) *) + if w * h < pixel_threshold then (if !debug_image_processing then Printf.printf "pixel threshold not met\n%!") else let size = match Pdf.lookup_direct pdf "/Length" dict with Some (Pdf.Integer i) -> i | _ -> 0 in if size < length_threshold then (if !debug_image_processing then Printf.printf "length threshold not met\n%!") else begin