[Tutor] [tutor] File format conversion

Varsha Purohit varsha.purohit at gmail.com
Wed Nov 14 00:12:20 CET 2007


Hello Alan,
     It is a file having colour data grid.. just like any simple ascii
file and i need to manipulate the numbers with colours. But at this
stage i am not much bothered with colurs i can associate it with
simple RGB value for all different numbers. ex. of such simple file
can be like this..
ncols         4
nrows         4
xllcorner     392800
yllcorner     5376340
cellsize      55
NODATA_value  -9999
9 3 7 3
8 3 2 7
3 2 1 3
3 7 3 2


and i need to associate each pixel of the image with this data in the
ascii... Did that help ??

thanks,
Varsha

On Nov 12, 2007 1:06 AM, Alan Gauld <alan.gauld at btinternet.com> wrote:
>
> "Varsha Purohit" <varsha.purohit at gmail.com> wrote
>
> >       In one application i want to convert format of ascii file to
> > binary file.
>
> That depends entirely on what the ASCII file contains.
> Is it a comma separated list of RGB values? Or is it
> a uuencode of the binary data? Or something else...
>
> > And using that binary file in a function of PIL i can
> > convert it to an image file.
>
> Depending on the formatting you may not need PIL,
> but it all depends on what the ASCII contains.
>
> > So i wanted to know how to convert the
> > file format in python... is it possible by Numpy ??
>
> You may only need one of the encode/decode libraries
> for something like uuencoding or maybe the struct module
> will do if its just raw bitmap data.
>
> > other alternative to convert an ascii into an bitmap image directly
> > in
> > PIL without Numpy??
>
> Yes you can always do it manually but it all depends
> on the format of the data.
>
> --
> Alan Gauld
> Author of the Learn to Program web site
> http://www.freenetpages.co.uk/hp/alan.gauld
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list