Simple HTTP Image Server
Project description
Simple HTTP Image Server
A drop-in replacement for python -m http.server
, albeit for images.
Quickstart
Install shis
.
$ pip install shis
Navigate to a directory/containing/images
.
$ cd /directory/containing/images
Remember python -m http.server
? Good.
$ python -m shis.server
# Serving HTTP on 0.0.0.0 port 7447. Press CTRL-\ (SIGQUIT) to quit.
# Processing images from : directory/containing/images
# Creating thumbnails in : directory/containing/images/shis
# Generating Website : 100%|████████████████████| 2/2 [00:00<00:00, 35.09it/s]
# Generating Thumbnails : 100%|███████████████| 120/120 [00:00<00:00, 132.48it/s]
There. You can now head over to http://0.0.0.0:7447/ (Or use your public IP instead).
Preview
Here's an example of what you can expect to see.
Features
- Drop-in replacement for
python -m http.server
, so it's easy on your brain. - Serves website even before creating thumbnails, so you don't have to wait.
- Uses multiple processes to create thumbails, so it's fast.
- Efficient resumes, so that further invocations are faster.
- Creates both small and large size thumbnails, so it's easy on your eyes.
- Minimal dependencies - just Pillow, Jinja2 and tqdm.
- Server side pagination, so it's easy on your browser.
- Tries to preserve EXIF orientation, so you don't have to rotate manually.
Usage
The following options are available. You can also access this via python -m shis.server -h
usage: python -m shis.server [-h] [--image-dir DIR] [--thumb-dir DIR]
[--previews] [--clean] [--ncpus CPUS]
[--pagination ITEMS] [--port PORT]
[--thumb-size SIZE] [--preview-size SIZE]
A drop in replacement for python -m http.server, albeit for images.
optional arguments:
-h, --help show this help message and exit
--image-dir DIR, -d DIR
directory to scan for images (default: current directory)
--thumb-dir DIR, -s DIR
directory to store thumbnails and website (default: shis)
--previews, -f create separate thumbnails for full screen previews
(takes more time)
--clean, -c remove existing thubnail directory (if exists)
--ncpus CPUS, -j CPUS
number of workers to spawn
(default: multiprocessing.cpu_count())
--pagination ITEMS, -n ITEMS
number of items to show per page (default: 200)
--port PORT, -p PORT port to host the server on (default: 7447)
--thumb-size SIZE size of the generated thumbnails in pixels (default: 256)
--preview-size SIZE size of full screen previews in pixels, if generated
(default 1024)
Further documentation can be found at shis.readthedocs.io.
Benchmarks
For comparison, I ran the following tools on the FFHQ Dataset. The dataset contains 70k images in 1024x1024 resolution for a total size of 90GB. The converted thumbnail size was set to 320x320 for all tools. The tests were done on a machine with an AMD EPYC 7401P CPU with 24 Cores, 32GB Memory and Python 3.6.10 running on Ubuntu 18.04. The config files used are provided below. All conversion times are in hh:mm:ss
format.
Library Version | Conversion Time | Configuration |
---|---|---|
shis 0.0.5 | 22:50 | default |
sigal 2.1.1 | 33:39 | sigal.conf.py |
thumbsup 2.14.0 | >1h | thumbsup.json |
Why another static gallery generator?
There are a bunch of static image servers (thumbsup, sigal, etc) available in a bunch of different languages (javascript, python, etc). While some of them like fgallery and curator haven't been developed in a while, others like thumbsup and sigal take a lot of time converting images. This repo is designed with just one use case in mind, and it plans to do it well. It aims to serve a large directory of images in the fastest and easiest way possible.
License
MIT License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file shis-0.0.9.tar.gz
.
File metadata
- Download URL: shis-0.0.9.tar.gz
- Upload date:
- Size: 61.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3738821b2a9a5f17907319bddff6cdfa7654afbab1ac7401b9423aa07bd2334 |
|
MD5 | 9cd3ec13666e4e5b0bedd136290c5955 |
|
BLAKE2b-256 | 4da098ab58f5d57ad22504ec98fb5aba7ca3ef5d29d4ebe8666f1451d782596a |
File details
Details for the file shis-0.0.9-py3-none-any.whl
.
File metadata
- Download URL: shis-0.0.9-py3-none-any.whl
- Upload date:
- Size: 61.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9fba0e7d28be00c926ef8a31b074d4da0ceca87c47006a41f96d8757917925e |
|
MD5 | 8c0340d5bc0d4013b3e864281f9135c0 |
|
BLAKE2b-256 | e3089080fd7072b06742181d947eebbee67dd363eb1d9022f52ebd90ef57fa1c |