[KimDaBa] perl -e 'my $advice ; use Kimdaba ; "" or die'

Jean-Michel FAYARD jmfayard at gmail.com
Mon Jan 17 12:26:37 GMT 2005


I hope some people on the list will find this interesting.
I've made a perl module ( "Kimdaba.pm" obviously)
that makes pretty easy to use infos from the database file
to do some quick&dirty extensions to Kimdaba,
to test new things or whatever you want.

To use it, unzip the zip file attached in your pictures directory.

As examples, I've made 
- a script that convert your KimDaBa database in a format understood by Digikam 
(version >=0.7 required, and a little program called sqlite is required too
but I think it comes with digikam)
- a script to really rotate your pictures.
In fact, the script does not really rotate the pictures, but it's only
a matter of calling your favorite command-line rotating tool
at the end of the tool.
( I have none and don't need one, because my digital camera correctly
translate the picture itself, but I think there is one in the
ImageMagick familiy)

So if you want to do your own extensions (export the database in another
format or whatever), it's quite simple, just copy and paste from kim_example.pl 

To use it, launch the kimdaba demo, let the files be stored in 
/tmp/kimdaba-demo-jmfayard or whatever, and type :
   $ ./kim_example.pl /tmp/kimdaba-demo-jmfayard

See, the script is pretty easy :
================ kim_example.pl ==================
#!/usr/bin/perl -w
use strict;
use Kimdaba;

my @ListOfPictures;
my $folder=getRootFolder();
parsedb( "$folder" );
    # parse the xml file and create two hashes:
    # %imageattributes	: HASH OF (url of the picture, REF. HASH OF
(attribute, value) )
    # %imageoptions	: HASH of (url, REF. HASH OF (optoin, REF. LIST OF value) )

my $nb1= scalar keys %imageattributes;
my $nb2= scalar keys %imageoptions;
print "I've found $nb1 pictures with attributes, and $nb2 with options\n";
printimage( (keys %imageattributes)[0] );
printimage( (keys %imageattributes)[$nb2] );

print "\n\n== NO Keywords  ==\n";
@ListOfPictures=matchAnyOption( "Keywords" => [] );
print join("\n", sort @ListOfPictures);

print "\n\n== Holiday  ==\n";
@ListOfPictures=matchAnyOption( "Keywords" => [ "holiday" ] );
print join("\n", sort @ListOfPictures);

print "\n\n== ANNE HELENE ==\n";
@ListOfPictures=matchAnyOption( "Persons" => [ "Anne Helene" ] );
print join("\n", sort @ListOfPictures);

print "\n\n== ANY OF (JESPER, ANNE HELEN) ==\n";
@ListOfPictures=matchAnyOption( "Persons" => [ "Jesper" , "Anne Helene" ] );
print join("\n", sort @ListOfPictures);

print "\n\n== ALL OF (JESPER, ANNE HELEN) ==\n";
@ListOfPictures=matchAllOptions( "Persons" => [ "Jesper" , "Anne Helene" ] );
print join("\n", sort @ListOfPictures);

print "\n\n== PERSONS=Jesper, Locations=Mallorca ==\n";
	"Persons" => [ "Jesper" ],
	"Locations" => [ "Mallorca" ]
print join("\n", sort @ListOfPictures);


PS : I wanted to put that on the wiki, but the website which hosts it
is down.

$ perl -e 'my $advice ; use Kimdaba ; "" or die'
Died at -e line 1.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: kim_perl.zip
Type: application/zip
Size: 5429 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kphotoalbum/attachments/20050117/f9f1568c/attachment.zip>

More information about the Kphotoalbum mailing list