Commit 39036dd1 authored by Stephane Glondu's avatar Stephane Glondu

Imported Upstream version 4.1.2

parent 6cba94a0
repo: e37886d73a98029822983bee73a2d90ceb4b298b
node: e4e7c50d80c2160f914a129758023bbdd75d86d3
branch: 4.1.1
latesttag: v4.0.1
latesttagdistance: 83
node: e70559bc4fcc98a125fee9fc8ced22237faa2d41
branch: for-release-4.1.2
tag: 4.1.2
4.1.2
* GIF lib version 5 support
* clang related compilation fixes
4.1.1
* omake --config clean up
* pkg-config is now used if exists in order to seek external libraries
......
......@@ -7,7 +7,7 @@ Requirements
To install CamlImages library, you need the following softwares:
* OCaml 4.00.1 or higher (OCaml 3.11 and above might work with small trivial fixes, but never tested)
* OCaml 4.01.0 or higher
* Findlib (aka ocamlfind, http://www.camlcity.org/archive/programming/findlib.html )
* OMake ( http://omake.metaprl.org/index.html )
......
......@@ -14,6 +14,19 @@
include OMyMakeroot
############################################################## Warnings
# For release, -warn-error should not be put
# OCaml 4.01.0
# OCAMLFLAGS= -w A-4-9-40-42-44-45
OCAMLFLAGS= -w A-4-9-40-42-44-45-37-41-35
# For the development, -warn-error A is turned on
if $(file-exists DEV)
OCAMLFLAGS += -warn-error A
export
########################################## External arguments
# Specify directories where X's rgb.txt can be found
......@@ -23,7 +36,7 @@ PATH_RGB_TXT[]=
########################################################################
VERSION=4.1.1
VERSION=4.1.2
# for src/META
PACKAGE_NAME=camlimages
......@@ -145,7 +158,7 @@ print_configured() =
LDFLAGS_gif=
SUPPORT_GIF=false
if $(true_if_not_defined ARG_WANT_GIF)
if $(not $(pkg_config gif, libgif))
if $(not $(pkg_config_between_vers gif, libgif, 4.0.0, 5.0.0))
HAVE_GIF = $(Check_header_library gif, gif_lib.h, DGifOpenFileName)
SUPPORT_GIF = $(HAVE_GIF)
if $(SUPPORT_GIF)
......@@ -164,7 +177,8 @@ print_configured() =
LDFLAGS_png=
SUPPORT_PNG=false
if $(true_if_not_defined ARG_WANT_PNG)
res=$(pkg_config png, libpng) # we need a separate statement to get the vars defined in pkg_config reflected.
# we need a separate statement to get the vars defined in pkg_config reflected.
res=$(pkg_config png, libpng)
if $(not $(res))
HAVE_PNG = $(Check_header_library png, png.h, png_create_read_struct)
SUPPORT_PNG = $(and $(HAVE_Z) $(HAVE_PNG))
......
......@@ -55,10 +55,6 @@ Check_ocamlfind_package(package) =
ConfMsgChecking($(package))
ConfMsgFound($(shell-success ocamlfind query $(package)))
Check_pkg_config(package, option) =
ConfMsgChecking(Freetype)
ConfMsgFound($(shell-success $(package)-config $(option)))
where1(com) =
WHERE = $(where $(prog))
if $(WHERE)
......@@ -230,3 +226,23 @@ pkg_config(name, libname) =
ConfMsgResult(failed $(PATH_PKG_CONFIG) $(libname))
value false
export
# PATH_PKG_CONFIG must be well defined
pkg_config_version(libname) =
value $(shell $(PATH_PKG_CONFIG) $(libname) --modversion)
pkg_config_between_vers(name, libname, min_ver, too_high_ver) =
if $(pkg_config $(name), $(libname))
ConfMsgChecking($(libname): $(min_ver) <= version < $(too_high_ver))
ver=$(pkg_config_version $(libname))
if $(and $(le $(cmp-versions $(min_ver), $(ver)), 0), $(lt $(cmp-versions $(ver), $(too_high_ver)), 0))
ConfMsgResult($(ver) ... yes)
value true
export
else
ConfMsgResult($(ver) ... no)
value false # do not export
export
else
value false
export
......@@ -2,7 +2,7 @@
CamlImages - Objective Caml image processing library
========================================================
The latest released version is 4.1.0.
The latest released version is 4.1.2.
========================================================
Note: This library is currently under development.
......@@ -22,7 +22,7 @@ Installation
Read the file INSTALL.txt
Using CamlImages
CamlImages concepts
========================================================
Color models
......@@ -120,6 +120,88 @@ when the program exits successfully. In other situations, for instance
in case of spurious exception, you may need to erase temporary files
manually.
Use of CamlImages
====================================
OCamlFind
------------------------------------
Due to the library complexity, we recommend using OCamlFind.
You can get the list of related packages by::
$ ocamlfind list | grep camlimages
camlimages (version: 4.1.2)
camlimages.all (version: 4.1.2)
camlimages.all_formats (version: 4.1.2)
camlimages.core (version: 4.1.2)
camlimages.exif (version: 4.1.2)
camlimages.freetype (version: 4.1.2)
camlimages.gif (version: 4.1.2)
camlimages.graphics (version: 4.1.2)
camlimages.jpeg (version: 4.1.2)
camlimages.lablgtk2 (version: 4.1.2)
camlimages.png (version: 4.1.2)
camlimages.ps (version: 4.1.2)
camlimages.tiff (version: 4.1.2)
camlimages.xpm (version: 4.1.2)
After successful installation of CamlImages, you should see something similar above.
At compilation of your program, you should list the packages of image formats and GUI of you needs.
But if you are not sure which one is required, just use 'camlimages.all':
it contains everything. Normally your compilation command should look like::
$ ocamlfind ocamlc -c -package camlimages.all blah.ml
to compile a module using CamlImages, or to build an executable,::
$ ocamlfind ocamlc -linkpkg -package camlimages.all blah.ml
Basic image manipulation
--------------------------------------
We have a basic image manipulation modules for each image pixel type:
Index8, Index16, Rgb24, Rgba32 and Cmyk32. All they have the same interface
documented in Image_intf.IMAGE.
Image saving/loading
--------------------------------------
To save or load an image to some image format, use the corresponding module
for the image format. Jpeg, Gif, Png and so on.
Here is a simple code to create a 1x1 RGB24 image and save it to a jpeg file::
(* save it to sample.ml *)
let () =
let img = Rgb24.create 1 1 in
Rgb24.set img 0 0 { Color.r = 255; g = 0; b = 0 };
Jpeg.save "sample.jpg" [] (Images.Rgb24 img)
You should be able to compile it by::
$ ocamlfind ocamlc -linkpkg -package camlimages.all -o sample sample.ml
and "./sample" should create an image file "sample.jpg".
(To run the code correctly, your CamlImages must be compiled with JPEG library.)
Examples
--------------------------------------
Some one-ML-file examples are found in CamlImages source directory.
Here are some recommendations:
* examples/edgedetect : Good to learn basic image loading/saving and pixel color manipulation
* examples/imgstat : Image header check which is written in pure OCaml code.
* tests/test.ml : Various image load/save tests displaying them on OCaml's Graphics window.
* examples/gifanim : How to handle Gif animation frames and how to write LablGtk app
* examples/resize : Resizing image
You can normally compile them by::
$ ocamlfind ocamlc -linkpkg -package camlimages.all -o XXX XXX.ml
Some may just fail because some of required libraries are not found in your system.
Where to report issues?
==========================================================
......
......@@ -12,5 +12,5 @@
(* $Id: usleep.ml,v 1.4 2004/09/23 06:56:23 weis Exp $ *)
let rec usleep sec = ignore (Unix.select [] [] [] sec);;
let usleep sec = ignore (Unix.select [] [] [] sec);;
......@@ -264,7 +264,7 @@ let resize w h cond old =
let create_pixbuf (_id : int) image filters =
let pixbuf = Imagegdk.to_pixbuf image in
let filters = sort_filters filters in
let rec filter_pixbuf pixbuf = function
let filter_pixbuf pixbuf = function
| [] -> pixbuf
| `SIZE (w, h, cond) :: _fs ->
(* original pixbuf will be GC'ed automatically *)
......
......@@ -82,7 +82,7 @@ end
let status_bar ?packing ?show () = new status_bar ?packing ?show ()
class img_button ?label ?frames ?border_width ?width ?height ?packing ?show () =
class img_button ?label ?frames ?packing ?show () =
let button = GButton.button (*?border_width ?width ?height*) ?packing ?show () in
let vbox = GPack.vbox ~packing: button#add () in
let pix =
......
......@@ -123,7 +123,7 @@ let guess link_as_link f =
end;;
let guess = guess false
and lguess = guess true;;
and _lguess = guess true;;
(* prerr_endline "reading suffix"; *)
read_suffix_file default_mime_types;;
Image processing library
An image processing library, which provides loading and saving various
image formats with an interface for the Caml graphics library. It has
also an interface with the freetype library to draw texts using
truetype fonts.
opam-version: "1"
maintainer: "jun.furuse@gmail.com"
build: [
["omake"]
["omake" "install"]
]
remove: [
["ocamlfind" "remove" "camlimages"]
]
depends: ["ocamlfind" "lablgtk" "omake"]
archive: "https://bitbucket.org/camlspotter/camlimages/get/v4.0.1.tar.gz"
Image processing library
An image processing library, which provides loading and saving various
image formats with an interface for the Caml graphics library. It has
also an interface with the freetype library to draw texts using
truetype fonts.
opam-version: "1"
maintainer: "jun.furuse@gmail.com"
build: [
["omake"]
["omake" "install"]
]
remove: [
["ocamlfind" "remove" "camlimages"]
]
depends: ["ocamlfind" "omake"]
depopts: ["lablgtk"]
homepage: "http://cristal.inria.fr/camlimages/"
license: "LGPL-2 with OCaml linking exception"
authors: [
"Jun Furuse"
"François Pessaux"
"Pierre Weis"
]
archive: "https://bitbucket.org/camlspotter/camlimages/get/4.0.2.tar.gz"
Image processing library
An image processing library, which provides loading and saving various
image formats with an interface for the Caml graphics library. It has
also an interface with the freetype library to draw texts using
truetype fonts.
opam-version: "1"
maintainer: "jun.furuse@gmail.com"
build: [
["omake" "--configure" "INCLUDES=/usr/include/libexif"]
["omake" "install"]
]
remove: [
["ocamlfind" "remove" "camlimages"]
]
depends: ["ocamlfind" "base-unix" "omake"]
depopts: ["lablgtk"]
homepage: "http://cristal.inria.fr/camlimages/"
license: "LGPL-2 with OCaml linking exception"
authors: [
"Jun Furuse"
"François Pessaux"
"Pierre Weis"
]
archive: "https://bitbucket.org/camlspotter/camlimages/get/4.1.0.tar.gz"
Image processing library
An image processing library, which provides loading and saving various
image formats with an interface for the Caml graphics library. It has
also an interface with the freetype library to draw texts using
truetype fonts.
opam-version: "1"
maintainer: "jun.furuse@gmail.com"
build: [
["omake" "--configure"]
["omake" "install"]
]
remove: [
["ocamlfind" "remove" "camlimages"]
]
depends: ["ocamlfind" "base-unix" "omake"]
depopts: ["lablgtk"]
ocaml-version: [>= "4.00.1"]
homepage: "https://bitbucket.org/camlspotter/camlimages"
license: "LGPL-2 with OCaml linking exception"
authors: [
"Jun Furuse"
"François Pessaux"
"Pierre Weis"
]
archive: "https://bitbucket.org/camlspotter/camlimages/get/4.1.1.tar.gz"
......@@ -9,7 +9,7 @@ remove: [
]
depends: ["ocamlfind" "base-unix" "omake"]
depopts: ["lablgtk"]
ocaml-version: [>= "4.00.1"]
ocaml-version: [>= "4.01.0"]
homepage: "https://bitbucket.org/camlspotter/camlimages"
license: "LGPL-2 with OCaml linking exception"
authors: [
......
......@@ -276,7 +276,7 @@ let load_image8data bih ic =
(* Absolute mode:
c represents the number of bytes which follow,
each of which contains the color index of a single pixel. *)
for i = 0 to c - 1 do
for _i = 0 to c - 1 do
let c1 = read_byte ic in
bitmap.[!bitmapindex] <- Char.chr c1;
incr x;
......@@ -288,7 +288,7 @@ let load_image8data bih ic =
| c ->
(* Encoded mode *)
let c1 = read_byte ic in
for i = 0 to c - 1 do
for _i = 0 to c - 1 do
bitmap.[!bitmapindex] <- Char.chr c1;
incr x;
incr bitmapindex
......@@ -417,13 +417,13 @@ let load_image24data bih ic =
let pp = ref 0 in
for i = bih.biHeight - 1 downto 0 do
pp := (i * bih.biWidth * 3);
for j = 0 to bih.biWidth - 1 do
for _j = 0 to bih.biWidth - 1 do
bitmap.[!pp + 2] <- Char.chr (read_byte ic); (* Blue *)
bitmap.[!pp + 1] <- Char.chr (read_byte ic); (* Green *)
bitmap.[!pp] <- Char.chr (read_byte ic); (* Red *)
pp := !pp + 3
done;
for j = 0 to pad - 1 do skip_byte ic done;
for _j = 0 to pad - 1 do skip_byte ic done;
done;
bitmap
;;
......@@ -438,7 +438,7 @@ let load_image32data bih ic =
let pp = ref 0 in
for i = bih.biHeight - 1 downto 0 do
pp := (i * bih.biWidth * 4);
for j = 0 to bih.biWidth - 1 do
for _j = 0 to bih.biWidth - 1 do
bitmap.[!pp + 2] <- Char.chr (read_byte ic); (* Blue *)
bitmap.[!pp + 1] <- Char.chr (read_byte ic); (* Green *)
bitmap.[!pp + 0] <- Char.chr (read_byte ic); (* Red *)
......@@ -646,7 +646,7 @@ let write_end_of_scan_line oc = write_byte oc 0; write_byte oc 0;;
let write_end_of_bitmap oc = write_byte oc 0; write_byte oc 1;;
(* Writing padding bytes. *)
let write_pad oc n = for i = 0 to n - 1 do write_byte oc 0 done;;
let write_pad oc n = for _i = 0 to n - 1 do write_byte oc 0 done;;
(* Run length encoding: write the number n of pixels encoded *)
(* the color number given by color index c *)
......
......@@ -54,3 +54,4 @@ val make : int -> int -> elt -> t;;
val copy : t -> t;;
val sub : t -> int -> int -> int -> int -> t;;
val resize : (float -> unit) option -> t -> int -> int -> t;;
val rawimage : t -> rawimage
......@@ -103,12 +103,12 @@ module DateTime = struct
let converter sec =
let open Unix in
let tm = Unix.gmtime sec in
{ year = tm.Unix.tm_year;
month = tm.Unix.tm_mon + 1;
day = tm.Unix.tm_mday;
hour = tm.Unix.tm_hour;
min = tm.Unix.tm_min;
sec = tm.Unix.tm_sec }
{ year = tm.tm_year;
month = tm.tm_mon + 1;
day = tm.tm_mday;
hour = tm.tm_hour;
min = tm.tm_min;
sec = tm.tm_sec }
in
if s.[4] = '\000' then
let sec =
......@@ -397,7 +397,6 @@ module Analyze = struct
*)
open Numbers
open IFD
open Entry.Pack
type datetime =
......@@ -456,6 +455,7 @@ module Analyze = struct
| _ -> `Unknown (tag, pack)
(* CR jfuruse: unused
module GPS = struct
type latitude = [ `North | `South ] * rational
type longitude = [ `East | `West ] * rational
......@@ -478,6 +478,7 @@ module Analyze = struct
map_datum : map_datum option
}
end
*)
let analyze_gps (tag, v) = match tag, v with
......
......@@ -7,8 +7,6 @@ module Numbers : sig
val string_of_srational : int32 -> int32 -> string
end
open Numbers
module Endian : sig
type t = Big | Little
val to_string : t -> string
......
......@@ -9,7 +9,6 @@ open Exifutil
open Exif
open Exif.Numbers
open Exif.IFD
open Exif.Entry.Pack
(* I have some photos from my old Android with non Ascii datetime.
......
open Format
module Format = struct
include Format
......
......@@ -45,7 +45,7 @@ let done_face face = Ftlow.done_face face.cont;;
let new_face t font idx =
let face = {cont = Ftlow.new_face t.cont font idx; ref = ref t} in
let info = Ftlow.face_info face.cont in
Gc.finalise (fun v -> Ftlow.done_face v.cont) face;
Gc.finalise done_face face;
face, info;;
let get_num_glyphs face = Ftlow.get_num_glyphs face.cont;;
......
......@@ -27,6 +27,11 @@
#include <gif_lib.h>
// GIFLIB_MAJOR is only defined in libgif >= 4.2.0
#if !defined(GIFLIB_MAJOR)
# define GIFLIB_MAJOR 4
#endif
value Val_GifColorType( GifColorType *color )
{
CAMLparam0();
......@@ -140,7 +145,13 @@ value dGifOpenFileName( value name )
GifFileType *GifFile;
int i;
if((GifFile = DGifOpenFileName( String_val(name) )) == NULL){
#if (GIFLIB_MAJOR <= 4)
GifFile = DGifOpenFileName( String_val(name) );
#else
GifFile = DGifOpenFileName( String_val(name), NULL);
#endif
if(GifFile == NULL){
failwith("DGifOpenFileName");
}
......@@ -161,7 +172,11 @@ void dGifCloseFile( value hdl )
segmentation faults */
((GifFileType *)hdl)->Image.ColorMap = NULL;
DGifCloseFile( (GifFileType *) hdl );
#if (GIFLIB_MAJOR <= 4)
DGifCloseFile( (GifFileType *) hdl);
#else
DGifCloseFile( (GifFileType *) hdl, NULL );
#endif
CAMLreturn0;
}
......
......@@ -25,6 +25,11 @@
#include <gif_lib.h>
// GIFLIB_MAJOR is only defined in libgif >= 4.2.0
#if !defined(GIFLIB_MAJOR)
# define GIFLIB_MAJOR 4
#endif
int list_length( value list )
{
CAMLparam1(list);
......@@ -51,7 +56,12 @@ ColorMapObject *ColorMapObject_val( value cmap )
fprintf(stderr, "Creating map with length = %d ...\n", len);
fflush(stderr);
*/
cmapobj = MakeMapObject( len, NULL );
#if (GIFLIB_MAJOR == 4)
cmapobj = MakeMapObject( len, NULL );
#else
cmapobj = GifMakeMapObject( len, NULL );
#endif
for(i=0; i< len; i++){
cmapobj->Colors[i].Red = Int_val(Field(Field(cmap,i),0));
cmapobj->Colors[i].Green = Int_val(Field(Field(cmap,i),1));
......@@ -67,7 +77,13 @@ value eGifOpenFileName( name )
GifFileType *GifFileOut;
if ((GifFileOut = EGifOpenFileName( String_val( name ), 0) )== NULL) {
#if (GIFLIB_MAJOR <= 4)
GifFileOut = EGifOpenFileName( String_val( name ), 0 );
#else
GifFileOut = EGifOpenFileName( String_val( name ), 0, NULL );
#endif
if (GifFileOut == NULL) {
failwith("EGifOpenFileName");
}
/* gcc -fwritable-strings is required to compile libungif */
......@@ -87,7 +103,11 @@ void eGifCloseFile( value hdl )
segmentation faults */
((GifFileType *)hdl)->Image.ColorMap = NULL;
#if (GIFLIB_MAJOR <= 4)
EGifCloseFile( (GifFileType *) hdl );
#else
EGifCloseFile( (GifFileType *) hdl, NULL );
#endif
CAMLreturn0;
}
......
......@@ -15,7 +15,6 @@
(* $Id: index16.ml,v 1.4 2009/07/04 03:39:28 furuse Exp $*)
module E = struct
open Color
type t = int
let bytes_per_pixel = 2
let get str pos =
......
......@@ -67,3 +67,4 @@ val create : int -> int -> t;;
val make : int -> int -> elt -> t;;
val copy : t -> t;;
val sub : t -> int -> int -> int -> int -> t;;
val rawimage : t -> rawimage
......@@ -15,7 +15,6 @@
(* $Id: index8.ml,v 1.4 2009/07/04 03:39:28 furuse Exp $*)
module E = struct
open Color
type t = int
let bytes_per_pixel = 1
let get str pos =
......
......@@ -67,3 +67,4 @@ val create : int -> int -> t;;
val make : int -> int -> elt -> t;;
val copy : t -> t;;
val sub : t -> int -> int -> int -> int -> t;;
val rawimage : t -> rawimage
......@@ -223,7 +223,7 @@ let save_cmyk_sample name opts =
done;
close_out oc;;
let rec find_jpeg_size ic =
let find_jpeg_size ic =
(* jump to the next 0xff *)
let rec loop () =
let rec jump_to_0xff () =
......
......@@ -2,7 +2,7 @@
/* */
/* Objective Caml */
/* */
/* Franois Pessaux, projet Cristal, INRIA Rocquencourt */
/* Franis Pessaux, projet Cristal, INRIA Rocquencourt */
/* Pierre Weis, projet Cristal, INRIA Rocquencourt */
/* Jun Furuse, projet Cristal, INRIA Rocquencourt */
/* */
......@@ -286,7 +286,7 @@ value jpegh, offset, buf;
}
/* no boundary checks */
value read_jpeg_scanlines( value jpegh, value buf, value offset, value lines )
void read_jpeg_scanlines( value jpegh, value buf, value offset, value lines )
{
CAMLparam4(jpegh,offset,buf,lines);
struct jpeg_decompress_struct *cinfop;
......
......@@ -18,15 +18,6 @@
open Color;;
module type COLORMAP = sig
type t
val size : t map -> int
val find_exact : t map -> t -> int
val add_color : t map -> t -> int
val add_colors : t map -> t list -> int list
val find_nearest : t map -> t -> int
end;;
class virtual ['a] map (cmap : 'a Color.map) = object
val mapobj = cmap
method colormap = mapobj
......
......@@ -228,7 +228,7 @@ end;;
class index8_wrapper img = object (self)
inherit oimage_impl
inherit OColor.rgbmap img.colormap as colormap
inherit OColor.rgbmap img.colormap
method image_class = ClassIndex8
method image = Index8 img
......@@ -298,7 +298,7 @@ end;;
class index16_wrapper img = object (self)
inherit oimage_impl
inherit OColor.rgbmap img.colormap as colormap
inherit OColor.rgbmap img.colormap
method image_class = ClassIndex16
method image = Index16 img
......
......@@ -18,6 +18,7 @@
#include "config.h"
#endif
#include "string.h"
#include "oversized.h"
#include <png.h>
......
......@@ -55,7 +55,7 @@ let string_of_magic_number = function
| P6 -> "P6";;
(* Auxiliaries: skipping comments and reading numbers into strings. *)
let rec skip_comment ic =
let skip_comment ic =
let rec r0 () =
match input_char ic with
| '#' -> r1 ()
......@@ -209,7 +209,7 @@ let rec read_ascii_bit ic =
let read_ascii_pbm_ic ic l c = read_raw_gen_ic read_ascii_bit ic l c max_byte;;
let rec read_ppm_ic ic =
let read_ppm_ic ic =
let mn, l, c = read_ppm_header ic in
let img =
match mn with
......
......@@ -311,7 +311,7 @@ let super_save file conf comments showpage images =
(Char.code buf.[adrs])
(Char.code buf.[adrs + 1])
(Char.code buf.[adrs + 2]) in
for i = 0 to 2 do
for _i = 0 to 2 do
p_ (sprintf "%02x" m)
done in
if not conf.mirror then
......
......@@ -65,3 +65,4 @@ val copy : t -> t;;
val sub : t -> int -> int -> int -> int -> t;;
val dump : t -> string;;
val unsafe_access : t -> int -> int -> string * int;;
val rawimage : t -> rawimage
......@@ -58,3 +58,4 @@ val create : int -> int -> t;;
val make : int -> int -> elt -> t;;
val copy : t -> t;;
val sub : t -> int -> int -> int -> int -> t;;
val rawimage : t -> rawimage
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment