[R] How to read .bmp files into R? read.pnm throws error

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Nov 22 05:23:33 CET 2003


On Fri, 21 Nov 2003, Duncan Murdoch wrote:

> On Fri, 21 Nov 2003 15:57:35 -0800, you wrote:
> >
> >Is there a way to read .bmp files into R? I have tried read.pnm from pixmap
> >package. It returned
> >
> >Error in pm.readmagicnumber(con) : Not a PNM format file
> >
> >Anyother ways to load bitmap images?
> 
> .bmp format is fairly simple, and is well documented (e.g. see
> www.wotsit.org).  It wouldn't be hard to write a reader using
> connections.
> 
> The only difficulty is that several pixel formats are available.
> However, if you have control of the creation of the files, you can
> choose 24 bit BMPs, which are the simplest to read.

Even easier is to convert .bmp to .pnm by an external utility. For
example, `convert' from the ImageMagick suite (www.imagemagick.org) can do
this.


-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list