I am trying to generate a RTF (Rich Text Format) file with images from Python 2.1.
Firstly with MS-Word 97, I have saved a file with RTF format which contained a jpeg-image. I have edited this RTF file with a text editor, and I have seen as MS-Word converts the jpeg-image in a hexadecimal sequence.
I would like to do the same process for converting a binary jpeg-image in a hexadecimal-sequence from Python. For it, I have maked the next process (using Python 2.1 and PIL library, in Windows):
import Image
im = Image.open("photo.jpg")
file = open("filename.txt", "wb")
file.write ( im.tostring ( "hex") )
With this process, I obtain a hexadecimal-sequence of the jpeg-image (in "filename.txt"). However, I am trying to work with this sequence but I can not do anything with it. I think this sequence is no valid, because I have replaced from a text editor the hexadecimal-sequence of MS-Word to the hexadecimal-sequence obtained by me, however when I open this file, MS-Word do not show the jpeg-image.
Also, the hexadecimal-sequence generates by MS-Word is not equal to the hexadecimal-sequence generates by the previous process.
Anybody could help me about this ?
Thank you very much.

Reply via email to