Haskell image libraries

Haskellers, To add image support to fdo-notify, I need an image type. Looking through Hackage, I didn't find any image library with the following features: * Load from a variety of formats (at least PNG and JPG, I'd say) * Efficient per-pixel access, or a way to dump the image into a ByteString as a bitmap (I need to serialise them into the protocol's bitmap format) Preferably, it should be possible to construct images programmatically too. Is there really no such library? It would be nice to have something like a Haskell equivalent of the Python Imaging Library, which is the de facto standard image library in Python and supports just about every type of operation on images you could ask for. Regards, Max

"Max" == Max Rabkin
writes:
Max> Haskellers, To add image support to fdo-notify, I need an Max> image type. Looking through Hackage, I didn't find any image Max> library with the following features: * Load from a variety of Max> formats (at least PNG and JPG, I'd say) * Efficient per-pixel Max> access, or a way to dump the image into a ByteString as a Max> bitmap (I need to serialise them into the protocol's bitmap Max> format) Preferably, it should be possible to construct images Max> programmatically too. Max> Is there really no such library? It would be nice to have Max> something like a Haskell equivalent of the Python Imaging Max> Library, which is the de facto standard image library in Max> Python and supports just about every type of operation on Max> images you could ask for. I've found nothing either, having searched recently. -- Colin Adams Preston Lancashire

There is a partial binding to libgd: http://hackage.haskell.org/packages/archive/gd/3000.4.0/doc/html/Graphics-GD... http://www.libgd.org/Main_Page But GD itself may not do what you want. - jeremy On Nov 8, 2009, at 8:34 AM, Max Rabkin wrote:
Haskellers,
To add image support to fdo-notify, I need an image type. Looking through Hackage, I didn't find any image library with the following features: * Load from a variety of formats (at least PNG and JPG, I'd say) * Efficient per-pixel access, or a way to dump the image into a ByteString as a bitmap (I need to serialise them into the protocol's bitmap format) Preferably, it should be possible to construct images programmatically too.
Is there really no such library? It would be nice to have something like a Haskell equivalent of the Python Imaging Library, which is the de facto standard image library in Python and supports just about every type of operation on images you could ask for.
Regards, Max _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

"Jeremy" == Jeremy Shaw
writes:
Jeremy> There is a partial binding to libgd: Jeremy> http://hackage.haskell.org/packages/archive/gd/3000.4.0/doc/html/Graphics-GD... Jeremy> http://www.libgd.org/Main_Page Jeremy> But GD itself may not do what you want. I ended up using this myself, but it is an unsatisfactory compromise (no support for TIFF - and many other formats, trashes EXIF information). In my innocence I had imagined that GTK (the GIMP ToolKit) would provide all the image manipulation facilities that the GIMP offers. But no. -- Colin Adams Preston Lancashire

Max Rabkin wrote:
Haskellers,
To add image support to fdo-notify, I need an image type. Looking through Hackage, I didn't find any image library with the following features: * Load from a variety of formats (at least PNG and JPG, I'd say) * Efficient per-pixel access, or a way to dump the image into a ByteString as a bitmap (I need to serialise them into the protocol's bitmap format) Preferably, it should be possible to construct images programmatically too.
Is there really no such library? It would be nice to have something like a Haskell equivalent of the Python Imaging Library, which is the de facto standard image library in Python and supports just about every type of operation on images you could ask for.
Regards, Max
Try AC-EasyRaster-GTK. It's a thin layer over Gtk2hs that I wrote precisely because it's so fiddly to do bitmapped graphics with Gtk2hs. (Vector graphics is delightfully easy with Cairo, but bitmap graphics requires manual bit-twiddling, and lots of simple but non-obvious API calls.) In particular, Easy Raster will trivially load and save PNG and JPEG images, and provide pixel-level read/write functions (either with or without bounds checks). What I haven't implemented is access to the underlying pixel array. There's a function ib_pixmap which will get you the GTK Pixmap object, from which you can obtain the pixel array. But it's not an IOArray or STArray or anything like that; it's some other datatype that implements the MArray class, so it doesn't buy you much. You might as well just use the pixel read/write functions from Easy Raster and manually iterate all pixels... (Another annoying quirk is that Gtk2hs doesn't provide a way to read or write an image from a handle, only from a real file, so naturally Easy Raster shares the same limitation.)

On Sun, 2009-11-08 at 16:34 +0200, Max Rabkin wrote:
To add image support to fdo-notify, I need an image type. Looking through Hackage, I didn't find any image library with the following features: * Load from a variety of formats (at least PNG and JPG, I'd say) * Efficient per-pixel access, or a way to dump the image into a ByteString as a bitmap (I need to serialise them into the protocol's bitmap format) Preferably, it should be possible to construct images programmatically too.
What about the imlib bindings [1]? The only problem is, that imlib doesn't provide a functional image type (you'll end up processing the image in the IO monad), but it works quite well (I used it for my Piet interpreter, which required basic image processing tasks like a labelling algorithm). HTH - Stephan [1] http://hackage.haskell.org/package/Imlib -- Früher hieß es ja: Ich denke, also bin ich. Heute weiß man: Es geht auch so. - Dieter Nuhr

On Sun, Nov 08, 2009 at 04:34:26PM +0200, Max Rabkin wrote:
To add image support to fdo-notify, I need an image type. Looking through Hackage, I didn't find any image library with the following features: * Load from a variety of formats (at least PNG and JPG, I'd say) * Efficient per-pixel access, or a way to dump the image into a ByteString as a bitmap (I need to serialise them into the protocol's bitmap format)
If all you want is loading, dumping and saving, there's DevIL[1]. http://hackage.haskell.org/package/Codec-Image-DevIL http://openil.sourceforge.net/ -- Felipe.

wxHaskell contains functions to read and write images, for example
imageGetPixels [1] and imageCreateFromPixelArray [2]
Met vriendelijke groet,
Henk-Jan van Tuyl
[1]
http://hackage.haskell.org/packages/archive/wxcore/0.10.13.0/doc/html/Graphi...
[2]
http://hackage.haskell.org/packages/archive/wxcore/0.10.13.0/doc/html/Graphi...
--
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--
On Sun, 08 Nov 2009 15:34:26 +0100, Max Rabkin
Haskellers,
To add image support to fdo-notify, I need an image type. Looking through Hackage, I didn't find any image library with the following features: * Load from a variety of formats (at least PNG and JPG, I'd say) * Efficient per-pixel access, or a way to dump the image into a ByteString as a bitmap (I need to serialise them into the protocol's bitmap format) Preferably, it should be possible to construct images programmatically too.
Is there really no such library? It would be nice to have something like a Haskell equivalent of the Python Imaging Library, which is the de facto standard image library in Python and supports just about every type of operation on images you could ask for.
Regards, Max
participants (7)
-
Andrew Coppin
-
Colin Paul Adams
-
Felipe Lessa
-
Henk-Jan van Tuyl
-
Jeremy Shaw
-
Max Rabkin
-
Stephan Friedrichs