[mercury-users] announced: libtiff foreign interface (caveats)

doug.auclair at logicaltypes.com doug.auclair at logicaltypes.com
Sun Feb 4 16:10:32 AEDT 2007


Dear all,

Logical Types has built a tiny interface to libtiff to read/write
RGBA simple images.  It is available at

http://www.logicaltypes.com/share/tiff-matrix-2007-02-03.tgz

>From the README:

----

This is a very small foreign interface to libtiff <http://www.libtiff.org>
that allows reading and writing of RGBA (Red/Blue/Green/Alpha) TIFF images
using the matrix protocol (included).

!WARNING! As I note in the foreign implementation, this protocol is
!WARNING! patently NOT THREAD-SAFE!  So DON'T USE THREADS with this protocol.


libtiff must be installed for this to work.  The (small) libtiff protocol
is provided by the tiffany module.  Some sample programs are included
to show how this all works on a provided image (tiff/output.tif):

* read_tiff - reads the image into a matrix (you probably wish to `head -3`)
* copy_write_tiff - copied the read tiff exactly to my.tif
* checker_write_tiff - overlays a red checker pattern on the read tiff,
                       saving it as checked.tif
* grey_write_tiff - converts checker.tif to greyscale (greyed.tif).

The Makefile provides run_all to build and run each in turn.  Or, to the point:

$ make run_all

does the whole shooting match.

The module tiffany provides two interfaces to libtiff:

        % read_to_matrix/1 opens a TIFF file, reads the TIFF as
        % RGBA pixels (ints).

:- func read_to_matrix(string) = array2d(int).
:- mode read_to_matrix(in) = out(array2d) is det.

        % write_as_tiff/2 takes a matrix(int) and stores it
        % as an RGBA TIFF in whatever format that doesn't make
        % me pull my hair out in frustration.

:- pred write_as_tiff(array2d(int)::in, string::in) is det.

-----

Sincerely,
Doug Auclair

--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list