1#!/usr/local/bin/perl
2
3use Image::IPTCInfo;
4
5chdir('demo_images');
6
7my @files = ('burger_van.jpg', 'dog.jpg');
8
9foreach my $filename (@files)
10{
11	# Create new IPTCInfo object for the file
12	my $info = new Image::IPTCInfo($filename);
13
14	# With this you can get a list of keywords...
15	my $keywordsRef = $info->Keywords();
16
17	# ...and specific attributes
18	print "file      : $filename\n";
19	print "caption   : " . $info->Attribute('caption/abstract') . "\n";
20	foreach $keyword (@$keywordsRef)
21	{
22		print "  keyword : $keyword\n";
23	}
24
25	# Create some mappings and extra data for messing
26	# with XML and SQL exports.
27	my %mappings = (
28		'caption/abstract'	=> 'caption',
29		'by-line'			=> 'byline',
30		'city'				=> 'city',
31		'province/state'	=> 'state');
32
33	my %extra = ('extra1'   => 'value1',
34				 'filename' => $filename);
35
36	print "\n------------------------------\n\n";
37
38	# Demo XML export, with and without extra stuff
39	print "xml follows:\n\n";
40	print $info->ExportXML('photo');
41
42	print "\nxml with extra stuff follows:\n\n";
43	print $info->ExportXML('photo-with-extra', \%extra);
44
45	print "\n------------------------------\n\n";
46
47	# Demo SQL export, with and without extra stuff
48	print "sql follows:\n\n";
49	print $info->ExportSQL('photos', \%mappings);
50
51	print "\n\nsql with extra stuff follows:\n\n";
52	print $info->ExportSQL('morephotos', \%mappings, \%extra);
53
54	print "\n\n------------------------------\n\n";
55}
56
57print "all done!\n\n";
58
59exit;
60
61