JPEG comments and PIL

Discussion in 'Python' started by Eugene Morozov, Sep 11, 2003.

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

    --
    Email: <jmv at online.ru>
    Eugene Morozov, Sep 11, 2003
    #1
    1. Advertising

  2. Eugene Morozov wrote:

    > 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>
    Fredrik Lundh, Sep 13, 2003
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gerrit Holl

    PIL: jpeg comment

    Gerrit Holl, Dec 23, 2003, in forum: Python
    Replies:
    1
    Views:
    355
    John P. Speno
    Dec 29, 2003
  2. Jeff Kunce

    RE: [Image-SIG] PIL: jpeg comment

    Jeff Kunce, Jan 2, 2004, in forum: Python
    Replies:
    0
    Views:
    426
    Jeff Kunce
    Jan 2, 2004
  3. Jack Wu
    Replies:
    0
    Views:
    512
    Jack Wu
    Sep 22, 2006
  4. lovaspillando
    Replies:
    0
    Views:
    1,006
    lovaspillando
    Aug 26, 2007
  5. Ivan Alameda Carballo
    Replies:
    0
    Views:
    473
    Ivan Alameda Carballo
    Aug 26, 2007
Loading...

Share This Page