JPEG comments and PIL

E

Eugene Morozov

Hello!
Is it possible to manipulate JPEG comments using PIL? I
didn't find corresponding methods in the PIL library. I
just want to write yet another image viewer and editor
(similar to gthumb only crossplatform and with better
comment editing interface and web album generation
feature ;)) which stores comments in the JPEG images
themselves.
Eugene
 
F

Fredrik Lundh

Eugene said:
Is it possible to manipulate JPEG comments using PIL? I
didn't find corresponding methods in the PIL library. I
just want to write yet another image viewer and editor
(similar to gthumb only crossplatform and with better
comment editing interface and web album generation
feature ;)) which stores comments in the JPEG images
themselves.

as of 1.1.4, PIL can read APP markers (see the app/applist attributes
of the Jpeg image object), but you cannot write them out again.

COM markers are not supported at all, but reading them should be trivial;
just change

0xFFFE: ("COM", "Comment", Skip)

to

0xFFFE: ("COM", "Comment", COM)

in PIL/JpegImagePlugin.py, and define this function before the
start of the MARKER table:

def COM(self, marker):
s = self.fp.read(i16(self.fp.read(2))-2)
self.app["COM"] = s # compatibility
self.applist.append(("COM", s))

</F>
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,015
Latest member
AmbrosePal

Latest Threads

Top