Any Python modules for manipulating JFIF file contents?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Kenneth McDonald

    Any Python modules for manipulating JFIF file contents?

    Warning: this post may display my utter ignorance of image file format
    facts.

    As part of a photo album program I'm working on, I'd like to be able
    to work with the metadata in JPEG files, which I understand are
    really JFIF files holding jpg data. Do any Python modules permit
    me to do this? I looked at PIL, but it seemed to operatre at a
    higher level, i.e. hiding the file-level implementation details.

    At the least I'd like to be able to :

    1) Extract the metadata (comments, thumbnails, etc)
    2) Extract the raw JPEG data (since I want to experiment with
    combining multiple images into a single 'album' file using
    gdbm file.)

    Writing would be nice, but is not necessary.

    Failing a Python module, can anyone suggest the best library
    to look at to wrap in a module?

    Thanks,
    Ken McDonald
  • Jeff Epler

    #2
    Re: Any Python modules for manipulating JFIF file contents?

    PIL can extract information like resolution.

    exifdump.py and EXIF.py can read the "EXIF" data that accompanies many
    photos taken on digital cameras. This can include a thumbnail,
    information like exposure time and focal length, and on some cameras it
    even tells you the orientation of the camera when the picture was taken.
    These two programs don't have any external requirements, they parse the
    JFIF and EXIF structures in pure Python.

    There are also Python wrappers for imlib and imagemagick, two other
    (unix) libraries often seen for image manipulation. I used imlib long
    ago, but I've never used imagemagick.

    My online photo albums (http://photos.unpy.net) use python with image
    metadata stored in a postgres database and the images themselves stored
    on the filesystem. It uses exifdump.py to read EXIF information. The
    source code to this is too nasty for me to consider sharing it with the
    world.

    More recently, I've been writing an image viewer in pygame, with the
    primary goal to reduce how often the user waits for a response. For
    instance, when the program is idle it preloads and scales the
    next/previous image in the image sequence. This has been fun (and I'm
    glad I learned pygame) but a user madly pressing "next" on an 800MHz
    machine can always get ahead of the computer trying to load 6 megapixel
    photos! To make things worse, PIL doesn't seem to release the GIL
    during long operations (such as loading a JPEG image or scaling it, each
    of which can take 2 seconds), and lacks progress callbacks (let alone a
    way to abort one of these operations in progress)...

    Have fun with your project!

    Jeff

    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.2.4 (GNU/Linux)

    iD8DBQFAvT8rJd0 1MZaTXX0RAjOBAJ 4sg/Li7V4wnmk34ouUk tf/Ui5JBQCfaEjp
    Gz9mDeMVrzZzLvD MocwoTLA=
    =swqX
    -----END PGP SIGNATURE-----

    Comment

    Working...