Image Processing in Pure?

87 views
Skip to first unread message

Johannes Engels

unread,
Nov 2, 2012, 1:24:44 PM11/2/12
to pure...@googlegroups.com
Hello, is anybody aware of an image processing package in Pure? Most urgently I would need functions which read and write *.jpg, *.png, *.tiff and/or *.bmp files. Or are there any wrappers of foreign libraries (e.g. devIL)?
Thanks in advance
Johannes

kp

unread,
Nov 4, 2012, 3:21:25 PM11/4/12
to pure...@googlegroups.com
I'm not aware of any, although that doesn't signify. I know XITE
http://www.mn.uio.no/ifi/english/research/groups/dsb/resources/software/xite/WHAT_IS_XITE.html
quite well and I guess it should be straightforward to get it into Pure.
Kurt

Yuri D'Elia

unread,
Nov 9, 2012, 12:37:38 PM11/9/12
to pure...@googlegroups.com
On 11/02/2012 06:24 PM, Johannes Engels wrote:
> Hello, is anybody aware of an image processing package in Pure? Most
> urgently I would need functions which read and write *.jpg, *.png, *.tiff
> and/or *.bmp files. Or are there any wrappers of foreign libraries (e.g.
> devIL)?

I always liked the media libraries from SGI and IL is no different, but
DevIL is not really maintained anymore (which is a shame).

If you just need to open random image files, Freeimage is probably
easier, but ImageMagick (and GraphicsMagick) open just about anything
and allow to run parallel/custom kernels on images quite easily (it's
probably on par with XITE afaik).

Albert Graef

unread,
Nov 11, 2012, 3:26:57 PM11/11/12
to pure...@googlegroups.com
On 11/02/2012 06:24 PM, Johannes Engels wrote:
> Hello, is anybody aware of an image processing package in Pure? Most
> urgently I would need functions which read and write *.jpg, *.png,
> *.tiff and/or *.bmp files. Or are there any wrappers of foreign
> libraries (e.g. devIL)?

Under pure-gl/examples you can find a pure-gen generated wrapper for
Imlib2. An example showing its use is in pure-gl/examples/texture.pure
(see line 23f.). I can't say whether this still works with the current
Imlib2 versions, but the Imlib2 header file is quite clean IIRC, so
generating your own wrapper with pure-gen should be a piece of cake. You
can find all that stuff either in the pure-gl package or in the hg repo
here:
http://code.google.com/p/pure-lang/source/browse/#hg%2Fpure-gl%2Fexamples

In my private repo I also found a wrapper for the ImageMagick library I
did some time ago. I never got around comitting it to the official repo
but I just tried it and it seems to work (on Linux at least). Note that
I don't have any examples for this, so you'll have to find your way
yourself. Anyway, I'm attaching this as a tarball, a Makefile is
included so that you can build the shared lib yourself (the Makefile is
for 64 bit Linux right now, but it should be easy to adapt it for other
systems). The wrapper was generated for ImageMagick 6.6.2.6 which is
what I have on my Ubuntu 11.04 system. If you have pure-gen installed,
you can also regenerate the wrapper with `make realclean all`. By
fiddling with the Makefile, you can probably also use this to generate a
wrapper for GraphicsMagick if you prefer that, but I haven't tried this yet.

If these don't fit your purpose, then it shouldn't be too hard to use
pure-gen in order to create your own wrappers of whatever C image
library your prefer. If you do, please post the results here so that
others can benefit. :)

HTH,
Albert

--
Dr. Albert Gr"af
Dept. of Music-Informatics, University of Mainz, Germany
Email: Dr.G...@t-online.de, a...@muwiinfa.geschichte.uni-mainz.de
WWW: http://www.musikinformatik.uni-mainz.de/ag
pure-magick.tar.bz2

Johannes Engels

unread,
Dec 21, 2012, 5:16:24 AM12/21/12
to pure...@googlegroups.com

Thank you for all your valuable suggestions! As I had never worked with the Pure-FFI or with pure-gen before, I was not aware how easy-to-use it is. In between I have experimented - mostly with Imlib - and did not encounter serious problems, the FFI worked smoothly. For instance, it was straightforward to import JPGs into Pure arrays.
At the moment I am struggling with the GDAL library, which seems to be more intricate but also more powerful as it supports a great variety of image formats.
Thanks again
Johannes
Reply all
Reply to author
Forward
0 new messages