[Tutor] image processing

Emile van Sebille emile at fenx.com
Tue Sep 23 23:48:49 CEST 2008


jeremiah wrote:
> I'm trying to do simple image manipulation but am getting an error. any
> ideas what i am doing wrong here?
> 
> Thanks
> JJ
> 
> #!/usr/bin/python
> import ImageFilter,Image
> name="test.jpg"
> file=open("./"+name,"w")

Right here you're opening the file in write mode, in effect creating a 
new file ready to be written to.  You probably want to use mode 'rb'

HTH,

Emile


> pic=Image.open(file)
> pic.rotate(45)
> pic.save("new_" + name)
> pic.show()
> 
> the error:
> 
> Traceback (most recent call last):
>   File "image_filter.py", line 7, in <module>
>     pic=Image.open(file)
>   File "/usr/lib/python2.5/site-packages/PIL/Image.py", line 1893, in
> open
>     prefix = fp.read(16)
> IOError: [Errno 9] Bad file descriptor
> 
> 
> 
> 
> Disclaimer: The information contained in this transmission, including any 
> attachments, may contain confidential information of Panasonic Avionics
> Corporation.  This transmission is intended only for the use of the 
> addressee(s) listed above.  Unauthorized review, dissemination or other use 
> of the information contained in this transmission is strictly prohibited. 
> If you have received this transmission in error or have reason to believe 
> you are not authorized to receive it, please notify the sender by return 
> email and promptly delete the transmission.
> 
> 
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
> 



More information about the Tutor mailing list