type(f) gives <type 'instance'>
yourimage = f.getvalue()
with open('myscrambledimage.dat', 'w') as f:
    f.write(yourimage)
so i coukld write this file to disk

now how can i convert this back to an image?
Thanks in advance


On Tue, Aug 12, 2014 at 1:14 AM, diliup gabadamudalige <dili...@gmail.com>
wrote:

> so if i need to save that to memory i do with open('writetomyfile.dat',
> 'w') as f.
>
> Thank you very much for that explanation.
>
> the "image save" part confused me.
> How would you convert the file back to a jpg or png image?
> Please pardon me for asking all these questions.
>
> Thank you very much in advance
>
>
> On Tue, Aug 12, 2014 at 1:08 AM, Radomir Dopieralski <pyg...@sheep.art.pl>
> wrote:
>
>> On 08/11/2014 09:34 PM, diliup gabadamudalige wrote:
>> > Dear Radomir,
>> >
>> > s = pygame.image.load("88keykbd.png")
>> > f = StringIO.StringIO()
>> > f.name <http://f.name> = '88keykbd.jpg'
>> > pygame.image.save(s, f)
>> > pygame.image.load("88keykbd.jpg")
>> >
>> >
>> > yourimage = f.getvalue()
>> >
>> > why does the line pygame.image.load("88keykbd.jpg") throw an error? It
>> > throws pygame.error: Couldn't open 88keykbd.jpg
>> > I cant find the88keykbd.jpeg in the path
>>
>> Of course you can't -- no such file exists. It's only in memory, in the
>> f variable. That's the whole point. You can get to the *contents* of
>> that variable with f.getvalue().
>>
>> --
>> The Sheep
>>
>
>
>
> --
> Diliup Gabadamudalige
>
> http://www.diliupg.com
> http://soft.diliupg.com/
>
>
> **********************************************************************************************
> This e-mail is confidential. It may also be legally privileged. If you are
> not the intended recipient or have received it in error, please delete it
> and all copies from your system and notify the sender immediately by return
> e-mail. Any unauthorized reading, reproducing, printing or further
> dissemination of this e-mail or its contents is strictly prohibited and may
> be unlawful. Internet communications cannot be guaranteed to be timely,
> secure, error or virus-free. The sender does not accept liability for any
> errors or omissions.
>
> **********************************************************************************************
>
>


-- 
Diliup Gabadamudalige

http://www.diliupg.com
http://soft.diliupg.com/

**********************************************************************************************
This e-mail is confidential. It may also be legally privileged. If you are
not the intended recipient or have received it in error, please delete it
and all copies from your system and notify the sender immediately by return
e-mail. Any unauthorized reading, reproducing, printing or further
dissemination of this e-mail or its contents is strictly prohibited and may
be unlawful. Internet communications cannot be guaranteed to be timely,
secure, error or virus-free. The sender does not accept liability for any
errors or omissions.
**********************************************************************************************

Reply via email to