########################################################### # A Perl package for showing/modifying JPEG (meta)data. # # Copyright (C) 2004,2005,2006 Stefano Bettelli # # See the COPYING and LICENSE files for license terms. # ########################################################### ########################################################### # This file contains only the package man-page in perldoc # # format. In order to visualise it, it is sufficient to # # type "perldoc ". # ########################################################### =head1 NAME Image::MetaData::JPEG - Perl extension for showing/modifying JPEG (meta)data. =head1 SYNOPSIS use Image::MetaData::JPEG; # Create a new JPEG file structure object my $image = new Image::MetaData::JPEG('somepicture.jpg'); die 'Error: ' . Image::MetaData::JPEG::Error() unless $image; # Get a list of references to comment segments my @segments = $image->get_segments('COM', 'INDEXES'); # Get the JPEG picture dimensions my ($dim_x, $dim_y) = $image->get_dimensions(); # Show all JPEG segments and their content print $image->get_description(); # Retrieve a specific value from Exif meta-data my $image_data = $image->get_Exif_data('IMAGE_DATA', 'TEXTUAL'); print $image_data->{DateTimeOriginal}->[0], "\n"; # Modify the DateTime tag for the main image $image->set_Exif_data({'DateTime' => '1994:07:23 12:14:51'}, 'IMAGE_DATA', 'ADD'); # Delete all meta-data segments (please, don't) $image->drop_segments('METADATA'); # Rewrite file to disk after your modifications $image->save('new_file_name.jpg'); # ... and a lot more methods for viewing/modifying meta-data, which # are accessed through the $file or $segments[$index] references. =head1 DESCRIPTION The purpose of this module is to read/modify/rewrite meta-data segments in JPEG (Joint Photographic Experts Group format) files, which can contain comments, thumbnails, Exif information (photographic parameters), IPTC information (editorial parameters) and similar data. Each JPEG file is made of consecutive I (tagged data blocks), and the actual row picture data. Most of these segments specify parameters for decoding the picture data into a bitmap; some of them, namely the Iment and Ilication segments, contain instead meta-data, i.e., information about how the photo was shot (usually added by a digital camera) and additional notes from the photograph. These additional pieces of information are especially valuable for picture databases, since the meta-data can be saved together with the picture without resorting to additional database structures. See the appendix about the L for technical details. This module works by breaking a JPEG file into individual segments. Each file is associated to an I structure object, which contains one I object for each segment. Segments with a known format are then parsed, and their content can be accessed in a structured way for display. Some of them can even be modified and then rewritten to disk. =over =item $JPEG::show_warnings This package variable must be used to inhibit the printing of warnings: if it is false, warnings are silently ignored. Otherwise, warning messages come with a detailed back-trace and description of the warning location. $Image::MetaData::JPEG::show_warnings = undef; =back =head2 Managing a JPEG structure object =over =item JPEG::new [arguments: C<($input, $regex, $options)>] The first thing you need in order to interact with a JPEG picture is to create an I structure object. This is done with a call to the I method, whose first argument is an I, either a I, interpreted as a file name to be opened and read, or a I, interpreted as a pointer to an in-memory buffer containing a JPEG stream. This interface is similar to that of L, but no open file handle is (currently) accepted. The constructor then parses the picture content and stores its segments internally. The memory footprint is close to the size of the disk file plus a few tens of kilobytes. my $file = new Image::MetaData::JPEG('a_file_name.jpg'); my $file = new Image::MetaData::JPEG(\ $a_JPEG_stream); The constructor method accepts two optional arguments, a I and an I