Is there a lib which support .jpeg file with "RGBA" mode?
google12 at mail.apol.com.tw
Sun Dec 14 17:35:18 CET 2003
Ann... I had tried to use Photoshop 7 to save a .png file with transparency
as a .jpg file, and the transparency will be kept in the .jpg file.
Thus, I don't know why...
Thanks for your help.
"Mike C. Fletcher" <mcfletch at rogers.com> ???
news:mailman.141.1071412755.9307.python-list at python.org ???...
> >Oh, sorry. I made a mistake...
> >My question is -- when I run the code described below, the transparence
> >the orginal image will be removed. How can I keep the transparence?
> > im = Image.open(test.png)
> > fp = open('test.jpg','wb')
> > im.save(fp,'JPEG')
> I believe the thrust of Fredrik's post was: you can't. JPEG does *not*
> store alpha channels. It's just not part of the format, so if you need
> to store in JPEG format, you will not be storing the alpha channel in
> the file.
> If what you're asking is whether you can store the alpha data to a
> separate file (as is done with programs such as 3DStudio Max), yes, that
> can be done too:
> >>> import Image
> >>> i = Image.open(
> >>> alpha = i.getdata( 3 )
> >>> i2 = Image.new( 'L', i.size, )
> >>> i2.putdata( alpha )
> >>> i2.save( r'p:\OpenGLContext\tests\wrls\simple_texturea.jpg', 'jpeg' )
More information about the Python-list