[R] PNG-import into R

tom wright tom at maladmin.com
Mon Nov 21 10:57:04 CET 2005


Hi,
I dont think you can import PNG images into R directly (although I may
be wrong). I use ImageMagick (available for most operating systems) and
the system() function to do my image conversions.

convertImage<-function(dirname,srcname,targetname){
    strSrcName<-shQuote(paste(dirname,srcname,sep='/'))
    strTrgName<-shQuote(paste(dirname,targetname,sep='/'))

    filelist<-system(paste('ls',strSrcName,sep=' '),TRUE,TRUE)
    if(length(filelist)<1){
        stop("Source Image Not Found")
    }

    filelist<-system(paste('ls',strTrgName,sep=' '),TRUE,TRUE)
    if(length(filelist)<1){
        strcmd<-paste('convert',strSrcName,strTrgName,sep=' ')
        system(strcmd)
    }
}

On Mon, 2005-21-11 at 11:36 +0100, Sydler, Dominik wrote:
> Hi there
> 
> I'm looking for a function to read PNG-bitmap-images from a file into R.
> I only found:
>  - the pixmap-package which cannot import png or similar formats
>  - the rimage-package which can only import lossy jpeg-images (the
> convertion from png to jpeg modifies the data!)
> 
> Is there any possibility to read PNG-files?
> 
> Thanks for any help
>          Dominic Sydler
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list