image module questions

Todd and I just talked about this. There are two possible

    > approaches, one of which should work and the other which we
    > would have to think about. The simpler approach is to write
    > a C extension using the Numeric API. As long as a small,
    > rarely-used, subset of the Numeric API is not used (the
    > UFunc API and some type conversion stuff in the type
    > descriptor)

OK, I'll start with plain vanilla Numeric along the lines Todd sent me
earlier, and we can do the (apparently straightforward)
numarray/numeric port when we have a prototype.

    > I agree that this is the drawback. On the other hand,
    > processor memory has grown much faster than image display
    > memory. With a full screen image of 1024x1280 pixels, we
    > are only talking about 5MB or so for a 32-bit deep
    > display. Converting rgba all to floats means 20MB, while
    > large is not overwhelming these days, and that is the worst
    > case for interactive cases. I suppose it would be a bigger
    > concern for non-interactive situations (e.g. PDF). But it
    > would seem that in doing this simpler approach, we would
    > have something that works sooner, and then we could think
    > about how to handle cases where someone wants to generate a
    > 4Kx4K PDF image (which is going to be one big PDF
    > file!). I'd let's not let extreme cases like this drive the
    > first implementation.

Agreed. If noone has any objections I think I'll start with rgba32 as
the common rendering format for the image module and we can special
case the smaller (grayscale UInt8 or UInt16) and larger (rgba floats)
cases after a prototype implementation.

I'm imagining an interface like

Frontend:

im = image.fromarray(A) # NxM
im = image.fromarray(A, colormap) # NxM colormapped images
im = image.fromarray(A) # NxMx3, no format needed
im = image.fromarray(A) # NxMx4, no format needed
im = image.fromfile('somefile.png')

im.set_interpolate(image.BILINEAR)
im.set_aspect_ratio(image.CONSTRAINED)

Backend:
  
  def draw_image(im):
      # Ascaled is width x height x 4 resampled using interpolation
      # and aspect constraints from above
      Ascaled = im.resize(viewport.width, viewport.height)
      renderer.draw_from_rgba(Ascaled, etc1, etc2)

    > Well, I was just referring to the image file support that
    > PIL supplies; the rest of PIL seems mostly redundant with
    > matplotlib and array capabilities (if I remember right, I
    > haven't really used PIL much). How much image file format
    > support is built into agg?

Almost none, except for the raw (or almost raw) image types (ppm,
bmp). PNG, I have more or less figured out; borrowing the read/write
capabilities for other image format from PIL is a good idea.

JDH