Is there a lib which support .jpeg file with "RGBA" mode?

G

google12

hi,

May anyone help me?

I need a lib which support .jpeg file with RGBA mode. PIL seems to support
RGB and CMYK mode only...

Thanks for your help.
 
F

Fredrik Lundh

google12 said:
May anyone help me?

I need a lib which support .jpeg file with RGBA mode. PIL seems to support
RGB and CMYK mode only...

last time I checked, JPEG didn't support RGBA.

</F>
 
G

google12

Oh, sorry. I made a mistake...

My question is -- when I run the code described below, the transparence of
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')
 
M

Mike C. Fletcher

google12 said:
Oh, sorry. I made a mistake...

My question is -- when I run the code described below, the transparence of
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:

HTH,
Mike

_______________________________________
Mike C. Fletcher
Designer, VR Plumber, Coder
http://members.rogers.com/mcfletch/
 
G

google12

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.
 
P

Peter Hansen

google12 said:
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.

If JPEG doesn't support transparency, then clearly that couldn't have happened,
or Photoshop uses a non-standard JPEG format.

Perhaps Photoshop "transparently" (no pun intended) saves the alpha data
to some other location, but magically restores it when you reload the .jpg?

(How have you confirmed that the data is really stored in the .jpg file
and not somewhere else?)
 
L

Lonnie Princehouse

Peter Hansen said:
...
Perhaps Photoshop "transparently" (no pun intended) saves the alpha data
to some other location, but magically restores it when you reload the .jpg?

That pun was _clearly_ intentional.
 
F

Fredrik Lundh

Peter said:
If JPEG doesn't support transparency, then clearly that couldn't have happened,
or Photoshop uses a non-standard JPEG format.

Perhaps Photoshop "transparently" (no pun intended) saves the alpha data
to some other location, but magically restores it when you reload the .jpg?

JPEG supports application-defined data segments ("app markers"), so Photoshop
may simply pack the alpha layer using a suitable lossless compression (predictor
plus zip?) and embed it inside the JPEG stream.

or they may ignore that fact that using lossy compression for alpha layers isn't
really a good idea...

if anyone can mail me a sample (or better, post a sample somewhere, and mail
me an URL), I can look into it.

</F>
 
P

Peter Hansen

Lonnie said:
That pun was _clearly_ intentional.

?? Actually it was not, but I'm unclear why you bother saying otherwise
without a smiley... were you trying to be funny, or do you somehow have
better knowledge of what I intended than I did?

(It was *unclearly* not intentional, perhaps, but it was not clearly intentional.)

-Peter
 
L

Lonnie Princehouse

Peter Hansen said:
?? Actually it was not, but I'm unclear why you bother saying otherwise
without a smiley... were you trying to be funny, or do you somehow have
better knowledge of what I intended than I did?

(It was *unclearly* not intentional, perhaps, but it was not clearly intentional.)

-Peter

I was just trying to be funny. I apologize if I've offended.
=)


</off topic posting>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,173
Messages
2,570,937
Members
47,481
Latest member
ElviraDoug

Latest Threads

Top