Lasco - a web picture gallery¶
Lasco is a web picture gallery written in Python with Pyramid. Yes, this is yet another image gallery. But this one is mine and comes with the right color scheme.
Features¶
Galleries, albums, pictures¶
With Lasco, you can set up any number of galleries. Each gallery is independent and may be managed by different users. The manager of a gallery may add albums. Albums may contain pictures, video and/or sound recordings. Items may have meta data: title, description, date and time. That is all. Only the title and the descriptin can be changed through a web interface. Extra picture metadata (camera model, exposure time, focal length, etc.) are not stored or shown anywhere in Lasco (although this could be added easily).
Access¶
Each gallery has a list of administrators. Each album has a list of viewers (that include administrators of the corresponding gallery). Users’ rights can be granted and revoked through the command-line interface.
Storage¶
Pictures are stored on the file system. Only one version (size) of a picture is needed. Lasco takes care of generating thumbnails of each picture when requested (and store them in a cache if you wish). Additional data is stored in a relational database.
Views¶
There are three views:
- an album view that lists 8 thumbnails (or a different number depending on the configuration);
- a picture view that shows a single picture resized to fit on a regular screen (that is, the screen of a computer, not the screen of a tablet or a phone);
- the picture itself in its original size.
Misc¶
The user interface is available in English and French (auto-detection of the user’s preferred language, possibly overriden by the user in the application) and comes with two themes (black or white background). Several access keys are implemented to facilitate the navigation in an album.
Installation and configuration¶
Dependencies and prerequisites¶
Lasco requires Python 2.7 and an RDBMS. I test with SQLite and use PostgreSQL on production. Other RDBMS should work as well.
Installation and configuration¶
Here below is the shortest path to test Lasco. It is highly recommended to install Lasco in a virtual environment:
$ mkdir test-lasco
$ cd test-lasco
$ mkdir src pics cache
$ cd src
$ # As of this writing, Lasco relies on a feature of
# 'repoze.bitblt' that has not yet been released
$ wget -O - --no-check-certificate https://github.com/repoze/repoze.bitblt/tarball/master | tar xvz
$ cd repoze-repoze.bitblt-*
$ python setup.py install
$ cd ../../
$ easy_install Lasco
You may check the installation with the following command:
$ lascocli --help
Usage: lascocli [-i FILE]
Options:
-h, --help show this help message and exit
-i FILE, --ini=FILE use FILE as the 'ini' file (default is './Lasco.ini')
On certain platforms (MacOS X 10.4, for example), you may have the following error:
ImportError: No module named readline
In this case, you need to install readline:
$ easy_install readline
Once you have installed the application, you need to fetch configuration files. Some development files are available from the source repository.
$ wget --no-check-certificate https://raw.github.com/dbaty/Lasco/master/dev.ini
$ wget --no-check-certificate https://raw.github.com/dbaty/Lasco/master/who.ini
Then edit dev.ini and change the following variables:
lasco.pictures_base_path = /path/to/test-lasco/pics
lasco.cache = /path/to/test-lasco/cache
You may also change the database, but a default SQLite will be good enough for a test.
If you do have pictures, copy them in a directory under /path/to/test-lasco/pics (for example in /path/to/test-lasco/pics/holidays-2010). If you do not have pictures at hand... wait, why would you want a gallery, then? Anyway, there are plenty of pictures set on the web, here is one with around 30 pictures:
$ cd pics
$ mkdir australia
$ cd australia
$ wget -r -np -nd -A "*.jpg" http://www.cs.washington.edu/research/imagedatabase/groundtruth/australia/
$ ls *.jpg | wc -l
30
$ cd ../..
You now need to record these pictures in Lasco. There is no web interface for this, you must use the command line interface.
$ lascocli -c dev.ini
lasco> gallery_add test "Test gallery"
=> Gallery has been added.
lasco> album_add test australia Australia /path/to/test-lasco/pics/australia
=> Album has been added.
Ok, our pictures are in the database, but you need a user account to access them. For this test, we will just create a gallery administrator, but you may create simple album viewers as well.
(continued from the 'lascocli' session above)
lasco> user_add test test test
lasco> gallery_users test +test
lasco> quit
All right, you are almost ready, you just need to install a WSGI server:
$ easy_install waitress
Finally, we can start the application:
$ pserve dev.ini
Starting server in PID 15304.
serving on http://0.0.0.0:6543
If you visit http://0.0.0.0:6543 and connect with the test login and the test password, you should be able to access the gallery and see your pictures.
User guide¶
The web user interface¶
FIXME: add obligatory screenshots?
Usage of the command-line interface¶
Lasco ships with a command-line interface that lets you add and remove galleries and albums, and grant and revoke users’ rights. There is no corresponding web user interface.
The command-line interface is available through the lascocli program. It includes its own help: run lascocli --help for further details. Running lascocli will get you to a prompt where you can issue commands. Type help for a list of commands. Type help <command> for a short description and the syntax of the given command.
There is limited auto-completion for most commands. For example, if the command requires the first argument to be a gallery, press the Tab key and you will get a list of all galleries.
Development¶
Contributions¶
Comments, feedback and contributions are most welcome. Do not hesitate to report bugs in the issue tracker or send a pull request on GitHub.
The source code evolved slowly over the last few years, from repoze.bfg to the latest versions of Pyramid, so the code may seem dated here and there...
How to run the tests¶
The test suite may be run with nosetests if you have installed Nose, or python setup.py test otherwise. By default, an in-memory SQLite database is used (which is fast). You may indicate a different database by setting a TESTING_DB environment variable. It should be a valid SQLAlchemy connection string, e.g.:
postgresql+psycopg2://lasco:lasco@localhost/lasco
The code should be 100% covered with the exception of a few lines in the command-line interface and the third-party EXIF module.
Development utilities¶
The source ships with a Makefile that contains a few utility rules, amongst which:
- coverage (or simply cov)
- make coverage runs Coverage.py, generates an HTML report and open it in your web browser.
- distcheck
- make distcheck verifies that your current version of the code can be correctly installed on a virgin virtual environment. It basically builds a source distribution, creates a temporary virtual environment, installs the distribution there and run the tests.
Credits¶
Lasco contains a module to extract EXIF information written by Gene Cash (see ext/exif.py for the license). The pencil icon comes from Mark James’ FamFamFam Silk icon set that is licensed under the Creative Commons Attribution 3.0 License (CC BY 3.0).
Lasco is written by Damien Baty and is licensed under the 3-clause BSD license, a copy of which is included in the source and reproduced below:
Copyright (c) 2012, Damien Baty All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of “Lasco” nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL DAMIEN BATY BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.