[Tutor] [tutor] File format conversion

Alan Gauld alan.gauld at btinternet.com
Mon Nov 12 10:06:49 CET 2007


"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 




More information about the Tutor mailing list