More work towards -lossless-resample-dpi
This commit is contained in:
parent
58e18a6caa
commit
22114c1fc4
|
@ -2677,7 +2677,7 @@ and specs =
|
||||||
("-lossless-resample",
|
("-lossless-resample",
|
||||||
Arg.Int setlosslessresample,
|
Arg.Int setlosslessresample,
|
||||||
" Resample lossless images to given part of original");
|
" Resample lossless images to given part of original");
|
||||||
("-lossless-resample",
|
("-lossless-resample-dpi",
|
||||||
Arg.Int setlosslessresampledpi,
|
Arg.Int setlosslessresampledpi,
|
||||||
" Resample lossless images to given DPI");
|
" Resample lossless images to given DPI");
|
||||||
("-resample-interpolate",
|
("-resample-interpolate",
|
||||||
|
|
15
cpdfimage.ml
15
cpdfimage.ml
|
@ -813,9 +813,9 @@ let process
|
||||||
| `List l -> hashset_of_list (map (function `Assoc (("Object", `Int i)::_) -> i | _ -> assert false) l)
|
| `List l -> hashset_of_list (map (function `Assoc (("Object", `Int i)::_) -> i | _ -> assert false) l)
|
||||||
| _ -> assert false
|
| _ -> assert false
|
||||||
in
|
in
|
||||||
let highdpi =
|
let highdpi, target_dpi_info =
|
||||||
let objnums =
|
let objnums, dpi =
|
||||||
if dpi_threshold = 0 then [] else
|
if dpi_threshold = 0 && factor > 0 then ([], []) else
|
||||||
let results = image_resolution pdf range max_float in
|
let results = image_resolution pdf range max_float in
|
||||||
(*iter (fun (_, _, _, _, wdpi, hdpi, objnum) -> Printf.printf "From image_resolution %f %f %i\n" wdpi hdpi objnum) results;*)
|
(*iter (fun (_, _, _, _, wdpi, hdpi, objnum) -> Printf.printf "From image_resolution %f %f %i\n" wdpi hdpi objnum) results;*)
|
||||||
let cmp (_, _, _, _, _, _, a) (_, _, _, _, _, _, b) = compare a b in
|
let cmp (_, _, _, _, _, _, a) (_, _, _, _, _, _, b) = compare a b in
|
||||||
|
@ -824,14 +824,17 @@ let process
|
||||||
(*iter (fun (_, _, _, _, wdpi, hdpi, objnum) -> Printf.printf "Lowest resolution exemplar %f %f %i\n" wdpi hdpi objnum) heads;*)
|
(*iter (fun (_, _, _, _, wdpi, hdpi, objnum) -> Printf.printf "Lowest resolution exemplar %f %f %i\n" wdpi hdpi objnum) heads;*)
|
||||||
let needed = keep (fun (_, _, _, _, wdpi, hdpi, objnum) -> fmin wdpi hdpi > float_of_int dpi_threshold) heads in
|
let needed = keep (fun (_, _, _, _, wdpi, hdpi, objnum) -> fmin wdpi hdpi > float_of_int dpi_threshold) heads in
|
||||||
(*iter (fun (_, _, _, _, wdpi, hdpi, objnum) -> Printf.printf "keep %f %f %i\n" wdpi hdpi objnum) needed;*)
|
(*iter (fun (_, _, _, _, wdpi, hdpi, objnum) -> Printf.printf "keep %f %f %i\n" wdpi hdpi objnum) needed;*)
|
||||||
map (fun (_, _, _, _, _, _, objnum) -> objnum) needed
|
map (fun (_, _, _, _, _, _, objnum) -> objnum) needed,
|
||||||
|
let r =
|
||||||
|
map (fun (_, _, _, _, wdpi, hdpi, objnum) -> (objnum, fmin wdpi hdpi)) heads
|
||||||
in
|
in
|
||||||
hashset_of_list objnums
|
iter (fun (x, d) -> Printf.printf "obj %i at %f dpi\n" x d) r; r
|
||||||
|
in
|
||||||
|
hashset_of_list objnums, hashset_of_list dpi
|
||||||
in
|
in
|
||||||
begin match onebppmethod with Some "JBIG2Lossy" -> preprocess_jbig2_lossy ~path_to_jbig2enc ~jbig2_lossy_threshold ~dpi_threshold ~length_threshold ~pixel_threshold inrange highdpi pdf | _ -> () end;
|
begin match onebppmethod with Some "JBIG2Lossy" -> preprocess_jbig2_lossy ~path_to_jbig2enc ~jbig2_lossy_threshold ~dpi_threshold ~length_threshold ~pixel_threshold inrange highdpi pdf | _ -> () end;
|
||||||
let nobjects = Pdf.objcard pdf in
|
let nobjects = Pdf.objcard pdf in
|
||||||
let ndone = ref 0 in
|
let ndone = ref 0 in
|
||||||
let target_dpi_info = if factor < 0 then [] else [] in
|
|
||||||
let process_obj objnum s =
|
let process_obj objnum s =
|
||||||
match s with
|
match s with
|
||||||
| Pdf.Stream ({contents = dict, _} as reference) ->
|
| Pdf.Stream ({contents = dict, _} as reference) ->
|
||||||
|
|
Loading…
Reference in New Issue