Pictures database and library mode; scan EXIF and IPTC metadata tags into a SQL db

  Thread Rating:
  • 2 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Thread Closed
solexalex Offline
Skilled Python Coder
Posts: 706
Joined: Jul 2004
Reputation: 6
Post: #11
Okay i know. The problem is known.
It is due to the fact that my lib only scan for 'jpg' down case not JPG upper case. This is not a problem for windows users but uggly for linux users.
This is already repaired and i just need to send the version to the repository. I will not at home to do that before tomorrow.
This new version will make possible the scan of any extension you like. Anyway, only jpg will got iptc and exif infos if available.
Wait til tomorrow and tell me what do you think
find
tslayer Offline
Team-XBMC Developer
Posts: 3,581
Joined: Oct 2003
Reputation: 12
Post: #12
Thanks Smile

42.7% of all statistics are made up on the spot

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
find
mhdebokx Offline
Member
Posts: 58
Joined: Dec 2006
Reputation: 0
Location: Netherlands
Post: #13
feature request to implement more EXIF.IPTCdata keywords, like
- Category
- SupplementalCategories
- CountryCode
- Country
- City

thanks in advance
find
solexalex Offline
Skilled Python Coder
Posts: 706
Joined: Jul 2004
Reputation: 6
Post: #14
hi mhdebokx
All of these are already scanned for and included in the pictures database. This is the job of my library mypicsdb.py

Unfortunately I don't really know how to include all of these within a plugin. That's why it is a library and a plugin using my library. I hope other devs could take advantage of my lib and create some scripts with full interface.

I'm thinking right now about your request, maybe can you be more explicit about what you want ? Maybe I can create some other folders like now we have 'by date, by fodler, by keywords, I may add 'by categories', 'by countrycode', ....
(You may be the only one interrested by this but I'm ready to code it for you (maybe can I think about a way to create any filters like the user want.
I.E you want a 'sort by City' folder.
The plugin show you all available fields (ie exif info and.or iptc info) and then create all the subfolders for you (like keywords filter)
City /
..../ Paris
..../ Cape Tribulation
..../ Sydney
......../Darling harbour.jpg
......../Circular Quay.jpg
......../.....
find
Robotica Offline
Posting Freak
Posts: 927
Joined: Aug 2010
Reputation: 3
Post: #15
In the previous topic I reported 2 bugs:
- Strange char in the foldername caused "ERROR: PICTURE: Error loading image F:\Foto's\100ÊSIO\CIMG0276.JPG"
- Time/date values from scan with TWAIN drivers causes problems:
Code:
03:23:34 M: 28311552 WARNING: -->Python Initialized<--
03:23:35 M: 25894912 NOTICE: using pysqlite2
03:23:36 M: 23371776 NOTICE: Q:\plugins\pictures\MyPictures (beta1)\MyPictures.db
03:23:36 M: 23330816 NOTICE: Scan folder :
03:23:36 M: 23347200 NOTICE: ["F:\\Foto's\\xx\\xxxxx\\"]
03:23:36 M: 23330816 NOTICE: F:\Foto's\xx\xxx\
03:23:37 M: 23306240 ERROR: Error Type: exceptions.ValueError
03:23:37 M: 23285760 ERROR: Error Contents: time data did not match format: data=2010.03.24 13.48.00 fmt=%Y:%m:%d %H:%M:%S
03:23:37 M: 23285760 ERROR: Traceback (most recent call last):
File "Q:\plugins\pictures\MyPictures (beta1)\default.py", line 427, in ?
ok = scan_my_pics()#scan lorsque le plugin n'a pas de paramètres
File "Q:\plugins\pictures\MyPictures (beta1)\default.py", line 404, in scan_my_pics
MPDB.browse_folder(chemin,parentfolderID=None,recu rsive=xbmcplugin.getSetting('recursive')=="true",u pdate=False,updatefunc = pupdate)
File "Q:\plugins\pictures\MyPictures (beta1)\resources\lib\MypicsDB.py", line 426, in browse_folder
exif = get_exif(os.path.join(dirname,picfile).encode('utf 8'))
File "Q:\plugins\pictures\MyPictures (beta1)\resources\lib\MypicsDB.py", line 528, in get_exif
tagvalue = time.strftime("%Y-%m-%d %H:%M:%S",time.strptime(tags[tag].__str__(),"%Y:%m:%d %H:%M:%S"))
File "Q:\system\python\python24.zlib\_strptime.py", line 292, in strptime
ValueError: time data did not match format: data=2010.03.24 13.48.00 fmt=%Y:%m:%d %H:%M:%S

Request:
Picture rating from GUI (probably needs XMP to store)
find
solexalex Offline
Skilled Python Coder
Posts: 706
Joined: Jul 2004
Reputation: 6
Post: #16
Hi robotica

You are doing good to write here your last requests.

* Unicode errors in the path are fixed just right now Smile It will be included in the next release.

* Datetime errors should be OK now.
It tries the standard datetime format (only dots separating the values) and if it does not work, try some others.
Sometimes it can't retrieve date time because as what I've seen in some pics, datime is 0000:00:00 00:00:00 and of course it is not a valid date time.

* XMP / picture rating
I haven't found any pure python library to retrieve XMP metadatas. I would love add this kind of metadatas as it is the most recent kind of information and it works with many different kind of file types.
If someone better than I am, knows about such a library, or if somebody knows how to use a XMP C library from python, feel free to contact me ! thank you
Picture rating may be done from scratch and only in and for mypictureDB.
Anyway, I say it again, it was not in my first thought to enable picture edition from this plugin as it requires a lot of attention to be safe and not corrupt your pics.
find
Robotica Offline
Posting Freak
Posts: 927
Joined: Aug 2010
Reputation: 3
Post: #17
Thnx for fixing that!

This EXIF-tool (http://www.sno.phy.queensu.ca/~phil/exiftool/) would be great but it's written in PERL. Maybe when jfcaroll is ready http://forum.xbmc.org/showthread.php?tid=80984 ....

Also found this: http://www.zoia.org/blog/2006/08/13/extr...ng-python/
(This post was last modified: 2010-09-13 23:04 by Robotica.)
find
solexalex Offline
Skilled Python Coder
Posts: 706
Joined: Jul 2004
Reputation: 6
Post: #18
I don't understand everything he says.... lol Hope it will be usefull later !
find
mhdebokx Offline
Member
Posts: 58
Joined: Dec 2006
Reputation: 0
Location: Netherlands
Post: #19
As mentioned per e-mail 2 kind of unicode problems occure. I hope there is a solution to translate in ascii strings to unicode

If photo's are geotagged using GeoSetter/ExifTools with option save IPTC in unicode, the next error occures:

08:34:53 T:880 M:248811520 NOTICE: MyPicsDB >> >>> DB_file_insert ...
08:34:53 T:880 M:248811520 NOTICE: MyPicsDB >> exceptions.Exception - You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.
08:34:53 T:880 M:248811520 NOTICE: MyPicsDB >> INSERT INTO files('GPS GPSLatitude','category','supplemental category','strFilename','country/primary location name','Image Model','Image Orientation','EXIF DateTimeOriginal','GPS GPSLongitude','UseIt','country/primary location code','EXIF DateTimeDigitized','contact','city','keywords','EXIF ExifImageWidth','idFolder','province/state','EXIF SceneCaptureType','strPath') values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)


some camera's also write unicode EXIF information, like the Canon 5D Mark II. The next error occures

08:34:53 T:880 M:248557568 ERROR: Error Type: exceptions.UnicodeEncodeError
08:34:53 T:880 M:248557568 ERROR: Error Contents: 'ascii' codec can't encode characters in position 61-62: ordinal not in range(128)
08:34:53 T:880 M:248516608 ERROR: Traceback (most recent call last):
File "C:\Documents and Settings\Michel\Application Data\XBMC\addons\plugin.image.mypicsdb\default.py", line 429, in ?
ok = scan_my_pics()#scan lorsque le plugin n'a pas de paramètres
File "C:\Documents and Settings\Michel\Application Data\XBMC\addons\plugin.image.mypicsdb\default.py", line 406, in scan_my_pics
MPDB.browse_folder(chemin,parentfolderID=None,recursive=xbmcplugin.getSetting(in​t(sys.argv[1]),'recursive')=="true",update=False,updatefunc = pupdate)
File "C:\Documents and Settings\Michel\Application Data\XBMC\addons\plugin.image.mypicsdb\resources\lib\MypicsDB.py", line 466, in browse_folder
iptc = get_iptc(dirname,picfile)
File "C:\Documents and Settings\Michel\Application Data\XBMC\addons\plugin.image.mypicsdb\resources\lib\MypicsDB.py", line 644, in get_iptc
log( "WARNING : '%s' is not a valid IPTC info (value : %s)"%(k,info.data[k][:80]) )
File "C:\Documents and Settings\Michel\Application Data\XBMC\addons\plugin.image.mypicsdb\resources\lib\MypicsDB.py", line 82, in log
print str("MyPicsDB >> %s"%msg)
UnicodeEncodeError: 'ascii' codec can't encode characters in position 61-62: ordinal not in range(128)
08:34:53 T:3732 M:248442880 ERROR: XFILE::CDirectory::GetDirectory - Error getting plugin://plugin.image.mypicsdb/
08:34:53 T:3732 M:248442880 ERROR: CGUIMediaWindow::GetDirectory(plugin://plugin.image.mypicsdb/) failed
find
solexalex Offline
Skilled Python Coder
Posts: 706
Joined: Jul 2004
Reputation: 6
Post: #20
Hum...
Your last error looks like an iptc info found in the picture is not valid. I need to test it this evening.
I think you sent me this pic and it is a good thing.
I'll add it to my library and watch for what is going wrong.
find
Thread Closed