Any Python modules for manipulating JFIF file contents?

  • Thread starter Kenneth McDonald
  • Start date
K

Kenneth McDonald

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
 
J

Jeff Epler

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)

iD8DBQFAvT8rJd01MZaTXX0RAjOBAJ4sg/Li7V4wnmk34ouUktf/Ui5JBQCfaEjp
Gz9mDeMVrzZzLvDMocwoTLA=
=swqX
-----END PGP SIGNATURE-----
 

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,537
Members
45,021
Latest member
AkilahJaim

Latest Threads

Top