1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
|
Lodju, an image organizer
=========================
by Lars Wirzenius <liw@iki.fi>
The way Lodju saves data to disk
--------------------------------
There are several ways in which Lodju could save data to disk:
1. As a plain text or XML file, with links to the original
files. Thumbnails would either have to be re-generated every
time or stored in ~/.thumbnails as per the Gnome/KDE thumbnail
managing standard.
2. As a plain file, but using a structure like tar or zip to
store all original files and thumbnails inside the file.
3. As a directory. This is basically the same as 2, but is
much simpler to implement, and does not suffer from file size
limitations on several filesystems.
I reject option 2, because it is unpleasant to implement and has
limitations that will be a problem. There are still systems in
use that have a problem with files larger than two gigabytes,
and with a camera that makes files of about 1,5 megabytes each,
that would limit a .lodju file to about 1400 pictures. I already
have over 6000 pictures that need to be organized.
Some comparisons between the other alternatives follow.
Use case 1. 3.
====================================================
Open from CLI: OK OK
"lodju foo.lodju"
"foo.lodju" is OK looks like
visible in Nautilus a directory
Open "foo.lodju" by OK opens
double-clicking in directory
Nautilus
Copy "foo.lodju" OK OK
to another directory
Copy "foo.lodju" images OK
to another computer must be
copied
separately
Burn "foo.lodju" to need to OK
a CD-ROM deal with
images
separately
Delete "foo.lodju" need to OK
and its images to delete
free up disk space images
separately
Alternative 1 is clumsy for anything that requires the index
file and the images to be copied somewhere. These are operations
that one would expect to be able to do with Nautilus without
any special consideration. It is also not robust against the
original files being moved using something else than Lodju.
Then the .lodju file will be broken; this requires a special
tool to find the new locations and reattach the links.
Alternative 3 would require the index file inside the directory
to be easily flagged in a way that will make Nautilus open Lodju.
It is still a bit clumsy.
Making HTML gallery templates
-----------------------------
The "Folder/Export to web" feature generates a gallery of the
selected folders. It generates the web pages using a number of
template files that contain HTML snippets. One set of such files
comes with Lodju; in the future, hopefully several. These template
files are searched in the directory decided at installation
time, and also in ~/.lodju/templates. This means that you can
experiment with creating your own templates by putting them in
~/.lodju/templates. This section describes how to do that in
some detail.
Each gallery template consists of several files in a directory
under ~/.lodju/templates. Thus, you can put several custom
templates there, for example:
~/.lodju/templates/company-website
~/.lodju/templates/flashy
~/.lodju/templates/test1
Each such directory must contain a bunch of files with the
suffix ".template":
folder-next-empty.template
folder-next.template
folder-prev-empty.template
folder-prev.template
folder.template
multi-folder-folder.template
multi-folder-index.template
photo-next-empty.template
photo-next.template
photo-prev-empty.template
photo-prev.template
photo.template
single-folder-index.template
thumbnail.template
All of these templates must exist. As far as Lodju is concerned,
the files are plain text files except that they can contain
Python formatting instructions of the form:
%(key)s
where "key" is a string (no whitespace) that indicates how the
formatting instruction is to be replaced in the output. For
example, the name of a photograph would be
%(photo.name)s
Not all keys are valid for all templates. Those that apply to
folders have the keys for the folder they are being applied to.
Those that apply to photos also have the keys for photo in
question.
The templates are used as follows:
1. If you are exporting only one folder, then the index.html
file is generated using single-folder-index.template and
thumbnail.template. First each photo is applied to the
thumbnail template and all of these are then concatenated
and applied to single-folder-index.template with the key
"thumbnails".
2. If, however, you are exporting several folders, the
index.html file is created using multi-folder-index.template
and multi-folder-folder.template. First each folder is
applied to multi-folder-folder.template, and the results
are concatenated and applied to multi-folder-index.template
using the key "folders".
Then each folder is applied to folder.template, similarly
to single-folder-index.template. The template may create
links to the next and previous folder using the templates
folder-{next,next-empty,prev,prev-empty}.template (the
-empty versions are used if there is no next or previous
folder). The results of those templates are available to the
folder.template template with the keys "folder.next-link"
and "folder.prev-link".
3. Each photo is applied to photo.template and its links are
created in a way similar to the folder next/previous links,
using photo-{next,next-empty,prev,prev-empty}.template.
4. Files without a suffix ".template" are copied verbatim to
the gallery directory. This makes it easy to add, say,
a CSS stylesheet or ornamental graphics.
The keys that can be used are anything that are attributes in
a Lodju index file (lodju.xml), for example:
folder.id identifier for folder
folder.name
photo.angle rotation angle
photo.description description of photo
photo.file-size size of file in bytes
photo.id identifier for photo
photo.imported-from file imported from
photo.imported-at time and date of import
photo.name name of photo
photo.exif:iso-speed ISO speed
photo.exif:exposure-time exposure time
photo.exif:flash was flash used?
photo.exif:focal-length focal length
photo.exif:date-time time and date of exposure
Additionally:
photo.parent folder.id (or "index") of folder
containing the photograph
photo.next-link link to next photo
photo.prev-link link to previous photo
folder.next-link link to next folder
folder.prev-link link to previous folder
folders list of folder for the multi-folder
index page
thumbnails list of thumbnails for folder indexes
In addition to the template files, the directory should contain a
file called ".htaccess" with contents similar to the one for the
"plain" template. Lodju makes its gallery HTML files using the
UTF-8 encoding of the Unicode character set. The default for HTML
has always been the ISO-8859-1 character set. Some web servers
insist on adding a HTTP header that specifies the character set
as ISO-8859-1 regardless of what the file actually contains.
In Apache, this behavior is controlled with the AddDefaultCharset
configuration directive. Luckily, this directive works in
.htaccess files, so Lodju makes one in the gallery directory
(i.e., it copies the file from the template directory).
With other web servers, .htaccess might not work, and you may need
to fix this some other way. Feel free to report such issues to
the Lodju mailing list so that Lodju can be adapted if necessary.
|