Automatic w, h determination for JBIG2
This commit is contained in:
parent
0d97d39c02
commit
cd9512a4de
16
cpdfimage.ml
16
cpdfimage.ml
|
@ -22,15 +22,16 @@ let pnm_to_channel_24 channel w h s =
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
let write_stream name stream =
|
|
||||||
let fh = open_out_bin name in
|
|
||||||
Pdfio.bytes_to_output_channel fh stream;
|
|
||||||
close_out fh
|
|
||||||
|
|
||||||
let jbig2_serial = ref 0
|
let jbig2_serial = ref 0
|
||||||
|
|
||||||
let jbig2_globals = null_hash ()
|
let jbig2_globals = null_hash ()
|
||||||
|
|
||||||
|
let write_stream name stream =
|
||||||
|
let fh = open_out_bin name in
|
||||||
|
Pdfio.bytes_to_output_channel fh stream;
|
||||||
|
close_out fh
|
||||||
|
|
||||||
let write_image ~raw ?path_to_p2p ?path_to_im pdf resources name image =
|
let write_image ~raw ?path_to_p2p ?path_to_im pdf resources name image =
|
||||||
match Pdfimage.get_image_24bpp pdf resources image with
|
match Pdfimage.get_image_24bpp pdf resources image with
|
||||||
| Pdfimage.JPEG (stream, _) -> write_stream (name ^ ".jpg") stream
|
| Pdfimage.JPEG (stream, _) -> write_stream (name ^ ".jpg") stream
|
||||||
|
@ -407,10 +408,13 @@ let obj_of_png_data data =
|
||||||
in
|
in
|
||||||
Pdf.Stream {contents = (Pdf.Dictionary d, Pdf.Got png.idat)}
|
Pdf.Stream {contents = (Pdf.Dictionary d, Pdf.Got png.idat)}
|
||||||
|
|
||||||
|
let jbig2_dimensions data =
|
||||||
|
(bget data 11 * 256 * 256 * 256 + bget data 12 * 256 * 256 + bget data 13 * 256 + bget data 14,
|
||||||
|
bget data 15 * 256 * 256 * 256 + bget data 16 * 256 * 256 + bget data 17 * 256 + bget data 18)
|
||||||
|
|
||||||
let obj_of_jbig2_data ?global:int data =
|
let obj_of_jbig2_data ?global:int data =
|
||||||
let d =
|
let d =
|
||||||
let w = 800 in
|
let w, h = jbig2_dimensions data in
|
||||||
let h = 1200 in
|
|
||||||
[("/Length", Pdf.Integer (Pdfio.bytes_size data));
|
[("/Length", Pdf.Integer (Pdfio.bytes_size data));
|
||||||
("/Filter", Pdf.Name "/JBIG2Decode");
|
("/Filter", Pdf.Name "/JBIG2Decode");
|
||||||
("/Subtype", Pdf.Name "/Image");
|
("/Subtype", Pdf.Name "/Image");
|
||||||
|
|
Loading…
Reference in New Issue