RGB specials
This commit is contained in:
parent
5321eb0c1f
commit
ba81e5fc6e
19
cpdfimage.ml
19
cpdfimage.ml
|
@ -640,7 +640,7 @@ let lossless_resample pdf ~pixel_threshold ~length_threshold ~factor ~interpolat
|
||||||
(*Printf.printf "***lossless_resample IN dictionary: %S\n" (Pdfwrite.string_of_pdf dict); *)
|
(*Printf.printf "***lossless_resample IN dictionary: %S\n" (Pdfwrite.string_of_pdf dict); *)
|
||||||
let in_components = test_components pdf dict in
|
let in_components = test_components pdf dict in
|
||||||
let in_bpc = test_bpc pdf dict in
|
let in_bpc = test_bpc pdf dict in
|
||||||
Printf.printf "\n***IN components = %i, bpc = %i\n" in_components in_bpc;
|
(*Printf.printf "\n***IN components = %i, bpc = %i\n" in_components in_bpc;*)
|
||||||
match lossless_out pdf ~pixel_threshold ~length_threshold ".png" s dict reference with
|
match lossless_out pdf ~pixel_threshold ~length_threshold ".png" s dict reference with
|
||||||
| None -> ()
|
| None -> ()
|
||||||
| Some (_, _, _, 4, _, _) -> Printf.printf "lossless resampling for CMYK not supported yet\n%!"
|
| Some (_, _, _, 4, _, _) -> Printf.printf "lossless resampling for CMYK not supported yet\n%!"
|
||||||
|
@ -668,8 +668,17 @@ let lossless_resample pdf ~pixel_threshold ~length_threshold ~factor ~interpolat
|
||||||
| Pdf.Stream {contents = Pdf.Dictionary d, data} as s ->
|
| Pdf.Stream {contents = Pdf.Dictionary d, data} as s ->
|
||||||
let out_components = test_components pdf s in
|
let out_components = test_components pdf s in
|
||||||
let out_bpc = test_bpc pdf s in
|
let out_bpc = test_bpc pdf s in
|
||||||
Printf.printf "***OUT components = %i, bpc = %i\n" out_components out_bpc;
|
(*Printf.printf "***OUT components = %i, bpc = %i\n" out_components out_bpc;*)
|
||||||
if out_components <> in_components || in_bpc <> out_bpc then
|
let rgb_to_grey_special =
|
||||||
|
let was_rgb =
|
||||||
|
match Pdf.lookup_direct pdf "/ColorSpace" dict with
|
||||||
|
| Some (Pdf.Name ("/DeviceRGB" | "/CalRGB")) -> true
|
||||||
|
| _ -> false
|
||||||
|
in
|
||||||
|
in_bpc = out_bpc && in_components = 3 && out_components = 1 && was_rgb
|
||||||
|
in
|
||||||
|
(*Printf.printf "***rgb_to_grey_special = %b\n" rgb_to_grey_special;*)
|
||||||
|
if (out_components <> in_components || in_bpc <> out_bpc) && not rgb_to_grey_special then
|
||||||
begin
|
begin
|
||||||
if !debug_image_processing then Printf.printf "wrong bpc / components returned. Skipping.\n%!";
|
if !debug_image_processing then Printf.printf "wrong bpc / components returned. Skipping.\n%!";
|
||||||
!reference
|
!reference
|
||||||
|
@ -677,9 +686,7 @@ let lossless_resample pdf ~pixel_threshold ~length_threshold ~factor ~interpolat
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
if !debug_image_processing then Printf.printf "lossless resample %i -> %i (%i%%)\n%!" size newsize (int_of_float (float newsize /. float size *. 100.));
|
if !debug_image_processing then Printf.printf "lossless resample %i -> %i (%i%%)\n%!" size newsize (int_of_float (float newsize /. float size *. 100.));
|
||||||
(* We will then test all the files we have available, and make sure all results correct *)
|
let d' = fold_right (fun (k, v) d -> if k <> "/ColorSpace" || rgb_to_grey_special then add k v d else d) d (match dict with Pdf.Dictionary x -> x | _ -> []) in
|
||||||
(* Then we will see about how to poke convert to do the correct thing - e.g not use PNG, force different output etc. *)
|
|
||||||
let d' = fold_right (fun (k, v) d -> if k <> "/ColorSpace" then add k v d else d) d (match dict with Pdf.Dictionary x -> x | _ -> []) in
|
|
||||||
(*Printf.printf "***lossless_resample OUT dictionary: %S\n" (Pdfwrite.string_of_pdf (Pdf.Dictionary d')); *)
|
(*Printf.printf "***lossless_resample OUT dictionary: %S\n" (Pdfwrite.string_of_pdf (Pdf.Dictionary d')); *)
|
||||||
(Pdf.Dictionary d', data)
|
(Pdf.Dictionary d', data)
|
||||||
end
|
end
|
||||||
|
|
BIN
cpdfmanual.pdf
BIN
cpdfmanual.pdf
Binary file not shown.
|
@ -3895,6 +3895,8 @@ Method & Effect\\\hline
|
||||||
|
|
||||||
\noindent It is not currently possible to reprocess lossless JBIG2 into lossy JBIG2, nor is it possible to recompress into CCITT.
|
\noindent It is not currently possible to reprocess lossless JBIG2 into lossy JBIG2, nor is it possible to recompress into CCITT.
|
||||||
|
|
||||||
|
NB: CYMK images will be converted to RGB by some of these processes. A future version of cpdf will remove this limitation.
|
||||||
|
|
||||||
\begin{cpdflib}
|
\begin{cpdflib}
|
||||||
\clearpage
|
\clearpage
|
||||||
\section*{C Interface}
|
\section*{C Interface}
|
||||||
|
|
Loading…
Reference in New Issue