Warning, /graphics/kphotoalbum/dev/documentation/database-layout.md is written in an unsupported language. File is not indexed.
0001 <!-- 0002 SPDX-FileCopyrightText: 2014-2023 Johannes Zarl-Zierl <johannes@zarl-zierl.at> 0003 SPDX-FileCopyrightText: 2018 Robert Krawitz <rlk@alum.mit.edu> 0004 0005 SPDX-License-Identifier: CC-BY-SA-4.0 0006 --> 0007 0008 Image database overview for KPhotoAlbum {#database-layout} 0009 ======================================= 0010 0011 Concepts 0012 -------- 0013 0014 ### Fuzzy Dates 0015 0016 KPhotoAlbum has the concept of fuzzy dates (or date intervals), which are defined by a start date 0017 and an end date (both include a timestamp). This helps for photos which have been digitized from an 0018 analog medium. 0019 0020 When the exact timestamp is known, startDate equals endDate. 0021 0022 0023 ### Directory structure 0024 0025 All images are expected to be located below a common root folder. The root folder is the one 0026 containing the index.xml database file. 0027 0028 All file names in the index.xml file are relative to the root folder. 0029 0030 0031 ### Tags 0032 0033 Tags (sometimes called Categories in KPhotoAlbum) are arranged in multiple independent 0034 hierarchies, i.e. there is no common root for all tags. 0035 0036 Tag hierarchies are organized as DAGs (directed acyclic graphs). 0037 0038 0039 ### Additional metadata 0040 0041 Exif information is stored in an sqlite database called `exif-info.db` in the image root folder. 0042 If the exif database is removed, it can be recreated from the image files. 0043 0044 0045 index.xml 0046 --------- 0047 0048 Below is a visualization of the DOM-Tree of the index.xml file. Attributes are 0049 within parenthesis, comments in square brackets. 0050 0051 ### Version 3 0052 Used in KPA v4.4 (and in KPA v4.5, if positionable tags are not used). 0053 0054 ``` 0055 KPhotoAlbum 0056 | (version=3,compressed=1) 0057 | 0058 +-Categories 0059 | +-Category (name,icon,show,viewtype,thumbnailsize) 0060 | +-value (value, id) 0061 | 0062 +-images 0063 | +-image 0064 | (file, label, startDate, endDate, angle, md5sum, width, height) 0065 | (description, stackId, stackOrder, rating, videoLength) [optional] 0066 | (#Categories.Category.name#=#Categories.Category.value.id#) [optional] 0067 | 0068 +-blocklist 0069 | +-block (file) 0070 | 0071 +-member-groups 0072 +-member (category,group-name,members) 0073 ``` 0074 0075 ``` 0076 KPhotoAlbum 0077 | (version=3,compressed=0) 0078 | 0079 +-Categories 0080 | +-Category (name,icon,show,viewtype,thumbnailsize) 0081 | +-value (value, id) 0082 | 0083 +-images 0084 | +-image 0085 | (file, label, startDate, endDate, angle, md5sum, width, height) 0086 | (description, stackId, stackOrder, rating, videoLength) [optional] 0087 | +-options 0088 | +-option(name=#Categories.Category.name#) 0089 | +-value(value=#Categories.Category.value.value#) 0090 | 0091 +-blocklist 0092 | +-block (file) 0093 | 0094 +-member-groups 0095 +-member (category,group-name,member) 0096 ``` 0097 0098 0099 ### Version 4 0100 Used in KPA v4.5. 0101 0102 ``` 0103 KPhotoAlbum 0104 | (version=4,compressed=1) 0105 | 0106 +-Categories 0107 | +-Category (name,icon,show,viewtype,thumbnailsize,positionable) 0108 | +-value (value, id) 0109 | 0110 +-images 0111 | +-image 0112 | (file, label, startDate, endDate, angle, md5sum, width, height) 0113 | (description, stackId, stackOrder, rating, videoLength) [optional] 0114 | (#Categories.Category.name#=#Categories.Category.value.id#) [optional] 0115 | +-options 0116 | +-option(name=#Categories.Category.name#) 0117 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0118 | 0119 +-blocklist 0120 | +-block (file) 0121 | 0122 +-member-groups 0123 +-member (category,group-name,members) 0124 ``` 0125 0126 ``` 0127 KPhotoAlbum 0128 | (version=4,compressed=0) 0129 | 0130 +-Categories 0131 | +-Category (name,icon,show,viewtype,thumbnailsize,positionable) 0132 | +-value (value, id) 0133 | 0134 +-images 0135 | +-image 0136 | (file, label, startDate, endDate, angle, md5sum, width, height) 0137 | (description, stackId, stackOrder, rating, videoLength) [optional] 0138 | +-options 0139 | +-option(name=#Categories.Category.name#) 0140 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0141 | 0142 +-blocklist 0143 | +-block (file) 0144 | 0145 +-member-groups 0146 +-member (category,group-name,member) 0147 ``` 0148 0149 #### Differences to version 3 0150 * Tags can be positionable, i.e. the ```images.image.options.option.value``` 0151 elements may have an additional attribute ```area```. 0152 * In the compressed format, ```images.image``` tags may have sub-elements ```options.option.value```. 0153 This format is used only for category values when an area attribute is present. 0154 0155 0156 ### Version 5 0157 Not used in an official release. 0158 0159 0160 ``` 0161 KPhotoAlbum 0162 | (version=5,compressed=1) 0163 | 0164 +-Categories 0165 | +-Category (name,icon,show,viewtype,thumbnailsize,positionable) 0166 | +-value 0167 | (value, id) 0168 | (birthDate) [optional] 0169 | 0170 +-images 0171 | +-image 0172 | (file, label, startDate, endDate, angle, md5sum, width, height) 0173 | (description, stackId, stackOrder, rating, videoLength) [optional] 0174 | (#Categories.Category.name#=#Categories.Category.value.id#) [optional] 0175 | +-options 0176 | +-option(name=#Categories.Category.name#) 0177 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0178 | 0179 +-blocklist 0180 | +-block (file) 0181 | 0182 +-member-groups 0183 +-member (category,group-name,members) 0184 ``` 0185 0186 ``` 0187 KPhotoAlbum 0188 | (version=5,compressed=0) 0189 | 0190 +-Categories 0191 | +-Category (name,icon,show,viewtype,thumbnailsize,positionable) 0192 | +-value 0193 | (value, id) 0194 | (birthDate) [optional] 0195 | 0196 +-images 0197 | +-image 0198 | (file, label, startDate, endDate, angle, md5sum, width, height) 0199 | (description, stackId, stackOrder, rating, videoLength) [optional] 0200 | +-options 0201 | +-option(name=#Categories.Category.name#) 0202 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0203 | 0204 +-blocklist 0205 | +-block (file) 0206 | 0207 +-member-groups 0208 +-member (category,group-name,member) 0209 ``` 0210 0211 #### Differences to version 4 0212 * ```Categories.Category.value``` has an optional attribute ```birthDate``` 0213 0214 0215 ### Version 6 0216 Used in KPA v4.6. 0217 0218 Same structure as version 5. 0219 0220 #### Differences to version 5 0221 * The legacy categories Keywords, Persons and Locations are not handled special any more. 0222 Upon upgrade from an older version, "Persons" is renamed to "People", and "Locations" 0223 is renamed to "Places". 0224 * Older versions of KPhotoAlbum stored the standard categories (People, Places, Events, Folder, 0225 Tokens, Media Type and Keywords; those have a translation) as their respective localized 0226 versions. This lead to several problems if a non-English locale was used and has been fixed in 0227 v4.6. Along with this update, it was also necessary to move all thumbnails in the CategoryImages 0228 directory refering to the old names and fix the respective category names in kphotoalbumrc. 0229 * The GPS related image tags (gpsAlt, gpsLat, gpsLon and gpsPrec) have been removed and are now 0230 superseded by storing GPS data in the EXIF database. 0231 0232 0233 ### Version 7 0234 Used in KPA v4.7 0235 0236 ``` 0237 KPhotoAlbum 0238 | (version=7, compressed=1) 0239 | 0240 +-Categories 0241 | +-Category 0242 | (name, icon, show, viewtype, thumbnailsize, positionable) 0243 | (meta) [optional] 0244 | +-value 0245 | (value, id) 0246 | (birthDate) [optional] 0247 | 0248 +-images 0249 | +-image 0250 | (file, label, startDate, endDate, angle, md5sum, width, height) 0251 | (description, stackId, stackOrder, rating, videoLength) [optional] 0252 | (#Categories.Category.name#=#Categories.Category.value.id#) [optional] 0253 | +-options 0254 | +-option(name=#Categories.Category.name#) 0255 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0256 | 0257 +-blocklist 0258 | +-block (file) 0259 | 0260 +-member-groups 0261 +-member (category,group-name,members) 0262 ``` 0263 0264 ``` 0265 KPhotoAlbum 0266 | (version=7, compressed=0) 0267 | 0268 +-Categories 0269 | +-Category 0270 | (name, icon, show, viewtype, thumbnailsize, positionable) 0271 | (meta) [optional] 0272 | +-value 0273 | (value, id) 0274 | (birthDate) [optional] 0275 | 0276 +-images 0277 | +-image 0278 | (file, label, startDate, endDate, angle, md5sum, width, height) 0279 | (description, stackId, stackOrder, rating, videoLength) [optional] 0280 | +-options 0281 | +-option(name=#Categories.Category.name#) 0282 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0283 | 0284 +-blocklist 0285 | +-block (file) 0286 | 0287 +-member-groups 0288 +-member (category,group-name,member) 0289 ``` 0290 0291 #### Differences to version 6 0292 The concept of translatable "standard" categories led to a lot of problems when users started KPA 0293 with different locales. Some of them simply can't be solved, so we decided to remove translatable 0294 category names. Now, each category is stored with it's literal name. 0295 Added an additional optional "meta" attribute to the Category-tag, so that the "Tokens" category (a 0296 "special" category like "Folder", but stored in the database and thus causing the same translation 0297 problems like the old "standard" categories) can be marked as such and does not need to have a fixed 0298 name anymore. 0299 0300 0301 ### Version 8 0302 Used in KPA v5.4 0303 0304 ``` 0305 KPhotoAlbum 0306 | (version=8, compressed=1) 0307 | 0308 +-Categories 0309 | +-Category 0310 | (name, icon, show, viewtype, thumbnailsize, positionable) 0311 | (meta) [optional] 0312 | +-value 0313 | (value, id) 0314 | (birthDate) [optional] 0315 | 0316 +-images 0317 | +-image 0318 | (file, startDate, md5sum, width, height) 0319 | (angle, description, endDate, label, rating, stackId, stackOrder, videoLength) [optional] 0320 | (#Categories.Category.name#=#Categories.Category.value.id#) [optional] 0321 | +-options 0322 | +-option(name=#Categories.Category.name#) 0323 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0324 | 0325 +-blocklist 0326 | +-block (file) 0327 | 0328 +-member-groups 0329 +-member (category,group-name,members) 0330 ``` 0331 0332 ``` 0333 KPhotoAlbum 0334 | (version=8, compressed=0) 0335 | 0336 +-Categories 0337 | +-Category 0338 | (name, icon, show, viewtype, thumbnailsize, positionable) 0339 | (meta) [optional] 0340 | +-value 0341 | (value, id) 0342 | (birthDate) [optional] 0343 | 0344 +-images 0345 | +-image 0346 | (file, startDate, md5sum, width, height) 0347 | (angle, description, endDate, label, rating, stackId, stackOrder, videoLength) [optional] 0348 | +-options 0349 | +-option(name=#Categories.Category.name#) 0350 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0351 | 0352 +-blocklist 0353 | +-block (file) 0354 | 0355 +-member-groups 0356 +-member (category,group-name,member) 0357 ``` 0358 0359 #### Differences to version 7 0360 0361 * ```images.image.angle``` is only saved when it differs from the default angle (0) 0362 * ```images.image.endDate``` is only saved when it differs from the start date 0363 * ```images.image.label``` is only saved when it differs from the default label 0364 0365 ### Version 9 0366 Used in KPA v5.10 0367 0368 ``` 0369 KPhotoAlbum 0370 | (version=9, compressed=1) 0371 | 0372 +-Categories 0373 | +-Category 0374 | (name, icon, show, viewtype, thumbnailsize, positionable) 0375 | (meta) [optional] 0376 | +-value 0377 | (value, id) 0378 | (birthDate) [optional] 0379 | (meta) [optional] 0380 | 0381 +-images 0382 | +-image 0383 | (file, startDate, md5sum, width, height) 0384 | (angle, description, endDate, label, rating, stackId, stackOrder, videoLength) [optional] 0385 | (#Categories.Category.name#=#Categories.Category.value.id#) [optional] 0386 | +-options 0387 | +-option(name=#Categories.Category.name#) 0388 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0389 | 0390 +-blocklist 0391 | +-block (file) 0392 | 0393 +-member-groups 0394 +-member (category,group-name,members) 0395 ``` 0396 0397 ``` 0398 KPhotoAlbum 0399 | (version=9, compressed=0) 0400 | 0401 +-Categories 0402 | +-Category 0403 | (name, icon, show, viewtype, thumbnailsize, positionable) 0404 | (meta) [optional] 0405 | +-value 0406 | (value, id) 0407 | (birthDate) [optional] 0408 | (meta) [optional] 0409 | 0410 +-images 0411 | +-image 0412 | (file, startDate, md5sum, width, height) 0413 | (angle, description, endDate, label, rating, stackId, stackOrder, videoLength) [optional] 0414 | +-options 0415 | +-option(name=#Categories.Category.name#) 0416 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0417 | 0418 +-blocklist 0419 | +-block (file) 0420 | 0421 +-member-groups 0422 +-member (category,group-name,member) 0423 ``` 0424 0425 #### Differences to version 8 0426 0427 * ```Categories.Category.value``` has an attribute "meta" with value "mark-untagged" for the untagged category tag. 0428 0429 ### Version 10 0430 0431 Not released yet. Used in KPA v5.12 0432 0433 ``` 0434 KPhotoAlbum 0435 | (version=10, compressed=1) 0436 | 0437 +-Categories 0438 | +-Category 0439 | (name, icon, show, viewtype, thumbnailsize, positionable) 0440 | (meta) [optional] 0441 | +-value 0442 | (value, id) 0443 | (birthDate) [optional] 0444 | (meta) [optional] 0445 | 0446 +-images 0447 | +-image 0448 | (file, startDate, md5sum, width, height) 0449 | (angle, description, endDate, label, rating, stackId, stackOrder, videoLength) [optional] 0450 | (#Categories.Category.name#=#Categories.Category.value.id#) [optional] 0451 | +-options 0452 | +-option(name=#Categories.Category.name#) 0453 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0454 | 0455 +-blocklist 0456 | +-block (file) 0457 | 0458 +-member-groups 0459 | +-member (category,group-name,members) 0460 | 0461 +-global-sort-order 0462 | +-item (category,item) 0463 ``` 0464 0465 ``` 0466 KPhotoAlbum 0467 | (version=10, compressed=0) 0468 | 0469 +-Categories 0470 | +-Category 0471 | (name, icon, show, viewtype, thumbnailsize, positionable) 0472 | (meta) [optional] 0473 | +-value 0474 | (value, id) 0475 | (birthDate) [optional] 0476 | (meta) [optional] 0477 | 0478 +-images 0479 | +-image 0480 | (file, startDate, md5sum, width, height) 0481 | (angle, description, endDate, label, rating, stackId, stackOrder, videoLength) [optional] 0482 | +-options 0483 | +-option(name=#Categories.Category.name#) 0484 | +-value(value=#Categories.Category.value.value#, area="x y w h") 0485 | 0486 +-blocklist 0487 | +-block (file) 0488 | 0489 +-member-groups 0490 | +-member (category,group-name,member) 0491 | 0492 +-global-sort-order 0493 | +-item (category,item) 0494 ``` 0495 0496 #### Differences to version 9 0497 0498 * New element ```global-sort-order``` 0499 0500 ### Attribute values explained 0501 0502 0503 * blocklist 0504 - block 0505 + ```file``` 0506 Relative filename to ignore. 0507 * Categories 0508 - Category 0509 + ```icon```<br/> 0510 XDG desktop icon name 0511 + ```name```<br/> 0512 Category name 0513 + ```show```<br/> 0514 ```0|1``` - hide or show category in the viewer. 0515 + ```thumbnailsize```<br/> 0516 Category-thumbnail size in pixel. 0517 + ```viewtype```<br/> 0518 Appearance of list views in the browser. 0519 ```TreeView=0, ThumbedTreeView=1, IconView=2, ThumbedIconView=3``` 0520 + ```positionable``` (since version=4 / KPA v4.5)<br/> 0521 ```0|1``` - indicates whether this category can contain areas (positioned tags) or not. 0522 + ```meta``` (since version=7 / KPA v5.7)<br/> 0523 Meta information that holds an unique id for special categories (so that they can be tracked when they are renamed for localization). 0524 + value 0525 * ```id```<br/> 0526 Numerical tag id, unique within each Category. 0527 * ```value```<br/> 0528 Tag name. 0529 * ```birthDate``` (since version=5 / KPA v4.6)<br/> 0530 Birthdate (```yyyy-mm-dd```) of a person (but allowed on all categories). 0531 Is used to display the age of a person on an image. 0532 * ```meta``` (since version=9 / KPA v5.10)<br/> 0533 Meta information that marks special tags (currently only "mark-untagged" for the tag which marks untagged images) 0534 * images 0535 - image 0536 + ```angle```<br/> 0537 Image rotation in degrees; between 0 and 359. 0538 + ```description```<br/> 0539 Description field; Text. 0540 + ```endDate```<br/> 0541 End date of the image (see fuzzy dates) (```yyyy-mm-dd[Thh:mm:ss]```, second optional part starts with uppercase 'T') 0542 + ```file```<br/> 0543 Relative path to the image file. 0544 + ```gpsAlt``` (since KPA 3.1, deprecated in version=6 / KPA v4.6)<br/> 0545 GPS altitude data, double. 0546 + ```gpsLat``` (since KPA 3.1, deprecated in version=6 / KPA v4.6)<br/> 0547 GPS latitude data, double. 0548 + ```gpsLon``` (since KPA 3.1, deprecated in version=6 / KPA v4.6)<br/> 0549 GPS longitude data, double. 0550 + ```gpsPrec``` (since KPA 3.1, deprecated in version=6 / KPA v4.6)<br/> 0551 GPS precision data, integer (-1 for "no precision data"). 0552 + ```heigth```<br/> 0553 Image height in pixel. 0554 + ```label```<br/> 0555 Textual label assigned to the image 0556 + ```md5sum```<br/> 0557 MD5 sum of the image file. 0558 + options 0559 * option 0560 - ```name```<br/> 0561 Category name; matches one of ```Categories.Category.name``` 0562 - value 0563 + ```value```<br/> 0564 Tag name; matches one of ```Categories.Category.value.value``` 0565 + ```area``` (since version=4 / KPA 4.5)<br/> 0566 Positional information for the tag. 0567 X,Y (upper left corner), width, height; all values in pixel. 0568 + ```rating``` (since KPA 3.1)<br/> 0569 Integer rating ("stars"), between 0 and 10. 0570 + ```stackId``` (since KPA 3.1)<br/> 0571 Numerical stack ID; images with the same stackId are displayed as an image stack. Stack ID starts with 1. 0572 + ```stackOrder``` (since KPA 3.1)<br/> 0573 Image position within a stack; only valid when stackId is set.<br/> 0574 Unique within the same stack. Stack order starts with 1. 0575 + ```startDate```<br/> 0576 Start date of the image (see fuzzy dates) (```yyyy-mm-dd[Thh:mm:ss]```, second optional part starts with uppercase 'T') 0577 + ```videoLength```<br/> 0578 Length of the video in seconds; -1 if length is not known. 0579 Only applicable to video files. 0580 + ```width```<br/> 0581 Image width in pixel. 0582 * member-groups 0583 - member 0584 + ```category```<br/> 0585 Category name; matches one of ```Categories.Category.name``` 0586 + ```group-name```<br/> 0587 Name of the group, may equal a Tag name and is usually displayed like a Tag name. 0588 + ```member``` (uncompressed format)<br/> 0589 A single tag name. 0590 + ```members``` (compressed format)<br/> 0591 Numerical tag ids, separated by comma. 0592 * global-sort-order 0593 - item 0594 + ```category```<br/> 0595 Category name; matches one of ```Categories.Category.name``` 0596 + ```item```<br/> 0597 A single tag name. 0598 0599 #### Encoding of category names 0600 0601 In the compressed format, category names are used as attributes to the images. 0602 In this context, the allowed character set is restricted by the rules for [XML attribute syntax](https://www.w3.org/TR/xml/#NT-NameStartChar), 0603 and category names therefore need to be escaped. 0604 0605 The details for character escaping can be seen here: 0606 * [XMLDB::FileWriter::escape()](@ref XMLDB::FileWriter::escape) 0607 * [XMLDB::FileReader::unescape()](@ref XMLDB::FileReader::unescape)