Fix image_resolution / image-resolution-json
This commit is contained in:
parent
5c4db2b52d
commit
06c3ee0204
4
Changes
4
Changes
|
@ -23,6 +23,10 @@ Extended features:
|
||||||
|
|
||||||
o Rectangle may be specified as x y x' y' rather than x y w h
|
o Rectangle may be specified as x y x' y' rather than x y w h
|
||||||
|
|
||||||
|
Fixes:
|
||||||
|
|
||||||
|
o -image-resolution-json was listing all images
|
||||||
|
|
||||||
* = Supported by a grant from NLnet
|
* = Supported by a grant from NLnet
|
||||||
|
|
||||||
2.7.1 (July 2024)
|
2.7.1 (July 2024)
|
||||||
|
|
|
@ -4405,8 +4405,7 @@ let go () =
|
||||||
let images = Cpdfimage.image_resolution pdf range f in
|
let images = Cpdfimage.image_resolution pdf range f in
|
||||||
iter
|
iter
|
||||||
(function (pagenum, xobject, w, h, wdpi, hdpi, objnum) ->
|
(function (pagenum, xobject, w, h, wdpi, hdpi, objnum) ->
|
||||||
if wdpi < f || hdpi < f then
|
Printf.printf "%i, %s, %i, %i, %f, %f, %i\n" pagenum xobject w h wdpi hdpi objnum)
|
||||||
Printf.printf "%i, %s, %i, %i, %f, %f, %i\n" pagenum xobject w h wdpi hdpi objnum)
|
|
||||||
images
|
images
|
||||||
| Some ListImages ->
|
| Some ListImages ->
|
||||||
let pdf = get_single_pdf args.op true in
|
let pdf = get_single_pdf args.op true in
|
||||||
|
|
15
cpdfimage.ml
15
cpdfimage.ml
|
@ -193,7 +193,7 @@ type xobj =
|
||||||
|
|
||||||
let image_results = ref []
|
let image_results = ref []
|
||||||
|
|
||||||
let rec image_resolution_page pdf page pagenum dpi images =
|
let rec image_resolution_page pdf page pagenum images =
|
||||||
try
|
try
|
||||||
let pageops = Pdfops.parse_operators pdf page.Pdfpage.resources page.Pdfpage.content
|
let pageops = Pdfops.parse_operators pdf page.Pdfpage.resources page.Pdfpage.content
|
||||||
and transform = ref [ref Pdftransform.i_matrix] in
|
and transform = ref [ref Pdftransform.i_matrix] in
|
||||||
|
@ -239,7 +239,7 @@ let rec image_resolution_page pdf page pagenum dpi images =
|
||||||
Pdfpage.rest = Pdf.Dictionary []}
|
Pdfpage.rest = Pdf.Dictionary []}
|
||||||
in
|
in
|
||||||
let newpdf = Pdfpage.change_pages false pdf [page] in
|
let newpdf = Pdfpage.change_pages false pdf [page] in
|
||||||
image_resolution newpdf [pagenum] dpi
|
image_resolution newpdf [pagenum]
|
||||||
| (pagenum, name, Image (w, h), objnum) ->
|
| (pagenum, name, Image (w, h), objnum) ->
|
||||||
let lx = Pdfunits.inches (distance_between o x) Pdfunits.PdfPoint in
|
let lx = Pdfunits.inches (distance_between o x) Pdfunits.PdfPoint in
|
||||||
let ly = Pdfunits.inches (distance_between o y) Pdfunits.PdfPoint in
|
let ly = Pdfunits.inches (distance_between o y) Pdfunits.PdfPoint in
|
||||||
|
@ -268,7 +268,7 @@ let rec image_resolution_page pdf page pagenum dpi images =
|
||||||
with
|
with
|
||||||
e -> Printf.printf "Error %s\n" (Printexc.to_string e); flprint "\n"
|
e -> Printf.printf "Error %s\n" (Printexc.to_string e); flprint "\n"
|
||||||
|
|
||||||
and image_resolution pdf range dpi =
|
and image_resolution pdf range =
|
||||||
let images = ref [] in
|
let images = ref [] in
|
||||||
Cpdfpage.iter_pages
|
Cpdfpage.iter_pages
|
||||||
(fun pagenum page ->
|
(fun pagenum page ->
|
||||||
|
@ -322,13 +322,16 @@ and image_resolution pdf range dpi =
|
||||||
iter
|
iter
|
||||||
(function (pagenum, images) ->
|
(function (pagenum, images) ->
|
||||||
let page = select pagenum pages in
|
let page = select pagenum pages in
|
||||||
image_resolution_page pdf page pagenum dpi images)
|
image_resolution_page pdf page pagenum images)
|
||||||
pagesplits
|
pagesplits
|
||||||
|
|
||||||
|
let is_below_dpi dpi (_, _, _, _, wdpi, hdpi, _) =
|
||||||
|
wdpi < dpi || hdpi < dpi
|
||||||
|
|
||||||
let image_resolution pdf range dpi =
|
let image_resolution pdf range dpi =
|
||||||
image_results := [];
|
image_results := [];
|
||||||
image_resolution pdf range dpi;
|
image_resolution pdf range;
|
||||||
rev !image_results
|
rev (keep (is_below_dpi dpi) !image_results)
|
||||||
|
|
||||||
let image_resolution_json pdf range dpi =
|
let image_resolution_json pdf range dpi =
|
||||||
let images = image_resolution pdf range dpi in
|
let images = image_resolution pdf range dpi in
|
||||||
|
|
Loading…
Reference in New Issue