Allow Exit JPEGs
This commit is contained in:
parent
53e3d92a81
commit
c964690434
|
@ -1,20 +1,25 @@
|
||||||
open Pdfutil
|
open Pdfutil
|
||||||
open Pdfio
|
open Pdfio
|
||||||
|
|
||||||
(* Return the width and height of a JPEG image, per Michael Petrov's C version. *)
|
(* Return the width and height of a JPEG image, per Michael Petrov's C version.
|
||||||
|
Altered to accept Exif too. *)
|
||||||
exception Answer of int * int
|
exception Answer of int * int
|
||||||
|
|
||||||
let jpeg_dimensions bs =
|
let jpeg_dimensions bs =
|
||||||
try
|
try
|
||||||
let get = bget bs in
|
let get = bget bs in
|
||||||
let i = ref 0 in
|
let i = ref 0 in
|
||||||
if get !i = 0xFF && get (!i + 1) = 0xD8 && get (!i + 2) = 0xFF && get (!i + 3) = 0xE0 then
|
if get !i = 0xFF && get (!i + 1) = 0xD8 && get (!i + 2) = 0xFF && (get (!i + 3) = 0xE0 || get (!i + 3) = 0xE1) then
|
||||||
begin
|
begin
|
||||||
i += 4;
|
i += 4;
|
||||||
if
|
if
|
||||||
get (!i + 2) = int_of_char 'J' && get (!i + 3) = int_of_char 'F'
|
get (!i + 2) = int_of_char 'J' && get (!i + 3) = int_of_char 'F'
|
||||||
&& get (!i + 4) = int_of_char 'I' && get (!i + 5) = int_of_char 'F'
|
&& get (!i + 4) = int_of_char 'I' && get (!i + 5) = int_of_char 'F'
|
||||||
&& get (!i + 6) = 0
|
&& get (!i + 6) = 0
|
||||||
|
||
|
||||||
|
get (!i + 2) = int_of_char 'E' && get (!i + 3) = int_of_char 'x'
|
||||||
|
&& get (!i + 4) = int_of_char 'i' && get (!i + 5) = int_of_char 'f'
|
||||||
|
&& get (!i + 6) = 0
|
||||||
then
|
then
|
||||||
let block_length = ref (get !i * 256 + get (!i + 1)) in
|
let block_length = ref (get !i * 256 + get (!i + 1)) in
|
||||||
while !i < bytes_size bs do
|
while !i < bytes_size bs do
|
||||||
|
|
Loading…
Reference in New Issue