Haskell image libraries

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Haskell image libraries

Max Rabkin-2
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
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell image libraries

Colin Paul Adams
>>>>> "Max" == Max Rabkin <[hidden email]> 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
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell image libraries

Jeremy Shaw-3
In reply to this post by Max Rabkin-2
There is a partial binding to libgd:

http://hackage.haskell.org/packages/archive/gd/3000.4.0/doc/html/Graphics-GD.html

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
> [hidden email]
> http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell image libraries

Andrew Coppin
In reply to this post by Max Rabkin-2
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.)

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell image libraries

Colin Paul Adams
In reply to this post by Jeremy Shaw-3
>>>>> "Jeremy" == Jeremy Shaw <[hidden email]> writes:

    Jeremy> There is a partial binding to libgd:
    Jeremy> http://hackage.haskell.org/packages/archive/gd/3000.4.0/doc/html/Graphics-GD.html

    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
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell image libraries

Stephan Friedrichs-3
In reply to this post by Max Rabkin-2
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

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell image libraries

Andrew Coppin
In reply to this post by Andrew Coppin
Max Rabkin wrote:

> On Sun, Nov 8, 2009 at 5:09 PM, Max Rabkin <[hidden email]> wrote:
>  
>> On Sun, Nov 8, 2009 at 4:58 PM, Andrew Coppin
>> <[hidden email]> wrote:
>>    
>>> Try AC-EasyRaster-GTK.
>>>      
>> Thanks, I'll give that a try
>>    
>
> Having downloaded it, I must admit I was a bit put off by seeing things like
> init_system :: IO ()
> process_event :: IO ()
> wait_event :: IO ()
> main_loop :: IO ()
> in an image library.
>
> But it's the best we've got right now, so I've got a couple questions:
> is it safe to call init_system more than once? And what do I need the
> event-handling functions for, if anything?
>  

If all you want to do is load/save images and do pixel I/O on them, you
can completely ignore process_event, wait_event, main_loop, etc. All you
need to do is make sure you call init_system at the start of your program.

(You see the ib_display function? If you want *that* to work properly,
you need to run the GTK event loop, which is what these event-related
functions are all about. If you're not trying to display the image on
screen, you can ignore all that.)

I should probably make the documentation clearer...

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell image libraries

Felipe Lessa
In reply to this post by Max Rabkin-2
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.
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell image libraries

Henk-Jan van Tuyl
In reply to this post by Max Rabkin-2

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/Graphics-UI-WXCore-Image.html#v:imageGetPixels
[2]  
http://hackage.haskell.org/packages/archive/wxcore/0.10.13.0/doc/html/Graphics-UI-WXCore-Image.html#v%3AimageCreateFromPixelArray


--
http://Van.Tuyl.eu/
http://members.chello.nl/hjgtuyl/tourdemonad.html
--


On Sun, 08 Nov 2009 15:34:26 +0100, Max Rabkin <[hidden email]>  
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
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Haskell image libraries

Pierre-Etienne Meunier-3
In reply to this post by Max Rabkin-2
there is also a binding for libGD on hackage :

http://hackage.haskell.org/package/gd

And, of course, you can improve it, or write a binding to a more  
complete library. Or, even better, write a mix between
http://www.libpng.org/pub/png/pngdocs.html
and
http://hackage.haskell.org/package/binary

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe