Module Jpeg
1 JPEG markers
module Marker : sig ... end
val load : string -> Images.load_option list -> Images.t
Loads a jpeg image.
val load_thumbnail : string -> Images.load_option list -> Geometry.spec -> int * int * Images.t
JPEG image data is composed so that thumbnails of the size 1/2, 1/4 and 1/8 of the original size can be loaded faster.
load_thumnail
loads an JPEG image with the one of these scales and 1/1 which is nearest and equal to or bigger than the givenGemetry.spec
.
val save : string -> Images.save_option list -> Images.t -> unit
Save a full-color image in jpeg format file. Raises
Invalid_argument
if the image is not a full-color image.
val save_with_markers : string -> Images.save_option list -> Images.t -> Marker.t list -> unit
Same as
save
but it also writes markers
val save_as_cmyk : string -> Images.save_option list -> (Images.rgb -> int * int * int * int) -> Images.t -> unit
Saves RGB24 image as a CMYK32 JPEG image, using the given color conversion function on the fly. More efficient than creating a CMYK24 image and saveing it.
val save_cmyk_sample : string -> Images.save_option list -> unit
Create CMYK jpeg image sample. Just for developpers.
Scanline based I/O functions
val open_in : string -> int * int * in_handle * Marker.t list
open_in path
opens a JPEG imagepath
and returns its width, height, a handle to get scanlines, and the JPEG makers.
val open_in_thumbnail : string -> Geometry.spec -> int * int * (int * int * in_handle) * Marker.t list
open_in_thumbnail
is the same asopen_in
but possibly scales down the image size based on the givenGeometry.spec
int the same way asload_thumbnail
.
val read_scanline : in_handle -> bytes -> int -> unit
read_scanline h buf off
reads a scanline from the handle and store inbytes
at the offsetoff
. (image's width * bytes_per_pixel) bytes are overwritten fromoff
ofbytes
. No size check ofbuf
is performed.
val close_in : in_handle -> unit
closes the given scanline handle
val open_out : string -> int -> int -> int -> out_handle
open_out path width height quality
opens a JPEG file atpath
, withwidth
,height
andquality
. It returns a scanline handle for write.
val write_marker : out_handle -> Marker.t -> unit
write_marker h m
writes a maker to JPEG. It must be performed before callingwrite_scanline
.
val write_scanline : out_handle -> bytes -> unit
write_scanline h buf
writes the contents ofbuf
to the write handle.buf
must have enough data for a scanline: (image's width * bytes_per_pixel) bytes of data must be available. No size check is performed.
val close_out : out_handle -> unit
Close the write handle
Accessing the header information without touching the pixel data
val check_header : string -> Images.header
Checks the file header
val read_markers : string -> Marker.t list
Open the file, read the markers, then close it immediately.