Skip to main content

Simple HTTP Image Server

GitHub PyPI - Python Version PyPI Documentation Status

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? Great.

$ python -m shis.server
# Serving HTTP on 0.0.0.0:7447. Press CTRL-C to quit.
# Processing images from : directory/containing/images
# Creating thumbnails in : directory/containing/images/shis
# Generating Website     : 100%|████████████████████|     4/    4 [00:00<00:00,  49.82it/s]
# Generating Thumbnails  : 100%|████████████████████|   300/  300 [00:00<00:00,  1.47kit/s]

There. You can now head over to http://0.0.0.0:7447/ (Or use your public IP instead).

TIP: You can install the latest development version directly from GitHub.

$ pip install git+https://github.com/nikhilweee/shis/

Preview

Here's an example of what you can expect to see. A live preview is also available at nikhilweee.github.io/shis. Demo

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 we build on past progress.
  • 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.
  • Displays the public IP (if exists), so you don't have to remember.

Usage

The following options are available. You can also access this via python -m shis.server -h. Further documentation can be found at shis.readthedocs.io.

usage: python -m shis.server [-h] [--image-dir DIR] [--thumb-dir DIR]
                             [--port PORT] [--pagination ITEMS] [--order ORDER]
                             [--ncpus CPUS] [--clean] [--previews]
                             [--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 dir)
  --thumb-dir DIR, -s DIR
                        directory to store generated content (default: shis)
  --port PORT, -p PORT  port to host the server on (default: 7447)
  --pagination ITEMS, -n ITEMS
                        number of items to display per page (default: 200)
  --order ORDER, -o ORDER
                        image listing order: name (default), random, original
  --ncpus CPUS, -j CPUS
                        number of workers to spawn (default: available CPUs)
  --clean, -c           remove existing --thumb-dir (if any) before processing
  --previews, -f        also generate fullscreen previews (takes more time)
  --thumb-size SIZE     size of generated thumbnails in pixels (default: 256)
  --preview-size SIZE   size of generated previews in pixels (default: 1024)

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 SHIS?

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. SHIS 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.

Acknowledgements

The demo at nikhilweee.github.io/shis shows sample images from the ImageNet dataset obtained through https://github.com/EliSchwartz/imagenet-sample-images. The gallery template used to display images is a modified version of the cards theme from https://github.com/thumbsup/theme-cards.

License

MIT License

Release files for shis 0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for shis 0.1
File Size Uploaded
shis-0.1.tar.gz 64.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for shis 0.1
File Interpreter ABI Platform
shis-0.1-py3-none-any.whl Python 3 none any Details

Total release size: 127.0 kB

Release files / shis-0.1.tar.gz

Download URL shis-0.1.tar.gz
Size 64.2 kB
Tags Source
SHA-256 checksum
How to use checksums
3acd68a1a48bf5f8da05126d92077b7390da1f18e7e53706413d67fb4337050d
BLAKE2b-256 checksum
How to use checksums
893b4b7d872c4b3a1403a041481d4754e690e0958cf55f6c352a18cbb989ef42
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5

Release files / shis-0.1-py3-none-any.whl

Download URL shis-0.1-py3-none-any.whl
Size 62.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
68f85ea5d6278bfb060daf929c8653b9deaaeea96f9045061ed89032e13ab797
BLAKE2b-256 checksum
How to use checksums
0c8e7c9b43c5c984c76d14eaf9cf6cde19c7ad2ef0d165e7772ef406133739dd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.6.1 requests/2.25.1 setuptools/51.0.0.post20201207 requests-toolbelt/0.9.1 tqdm/4.55.1 CPython/3.8.5

Release history Release notifications | RSS feed

This release

0.1 This release

2 release files

0.0.9

2 release files

0.0.8

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page