[icon]

thumbspage — Turn Folders into HTML Image Galleries

Version:  3.0.1, August 12, 2025 (changes)
License:  Provided freely, but with no warranties of any kind
Author:  © M. Lutz (learning-python.com) 2016-2025
Views:  Any PC or mobile browser, local or remote
Builds:  Any host that runs Python 3.X and Pillow
Installs:  thumbspage, any Python 3.X, and Pillow
See also:  web pagelive demoscreenshotsclient

Welcome to the thumbspage manual. This guide is meant for content creators and consumers of all kinds. It includes an overview of the program, detailed usage information, and a look at what's been upgraded in each release. Whether you consider yourself a developer or user, you'll find resources here to help you get started building and viewing image galleries with thumbspage.

Because thumbspage adds items to the images source folder and may rotate photos there, you are encouraged to read this guide first—especially its usage caution—before running thumbspage on valued picture collections. But if you're in a hurry: for a quick preview, try a live demo, packaged examples, or the code. You can also click the image above to test-drive the original use case, and take a brief tour of this program at its web page.

Contents

3.0 Quick Start

Because this program has evolved over time, this section summarizes the current state of using and building galleries as of thumbspage's latest version, 3.0. Later sections of this guide go into more details on this summary's topics. For more context, also see the 3.0 demo and screenshot galleries.

Viewing Galleries

Thumbspage galleries work on all commonly used desktop and mobile browsers, both online and offline. View a gallery by opening its main file, normally named index.html. You can open this file by visiting the gallery's web URL in your browser or by clicking its local version in a file explorer.

The index.html file is known as the index page; its thumbnails open viewer pages for individual images when tapped. Depending on the gallery, both page types may be colorized per the light or dark display-mode setting on your device. Change your mode to see the effect. The next sections cover these pages' usage.

Index Pages

An index page displays thumbnails for all the images in a gallery. Depending on how a gallery is built, resizing the window or display either reorganizes thumbnails to fit the new space or makes them accessible with horizontal scrolls as needed.

Scroll index pages vertically to view more thumbnails, using your device's normal scrolling techniques (e.g., swipe, bar, or mousewheel). Click the Top button at the bottom when it's available to jump to the top of the index, and tap any thumbnail to open an image's viewer page.

Viewer Pages

A viewer page displays one image in the gallery, scaled to fit the view. Resizing the window or display automatically rescales the image to fit the new available space. In a viewer page, navigate and invoke other actions with:

About swipes: For touchscreens, perform swipe gestures on image itself, using one finger. For touchpads and mousewheels, the location of the mouse cursor does not matter for swipes, and swipes may use two fingers on touchpads. Touchpad and mousewheel swipes are more laggy than touchscreen swipes or keyboard presses and best kept short.

Also note that your system settings may invert swipe directions. A down swipe, for instance, may mean swiping toward either the bottom or top of your display, depending on your settings, and the meaning of left and right swipes can be swapped by both your settings and gallery builds. Experiment with swipes on your device to see which actions they trigger.

The following actions are available on all viewer pages:

Back to index: Index tap, i key, browser back
To return to the index page, tap Index, press keyboard key i, or use your browser's back action (a button or gesture also called Back). Your browser's back action returns to your prior position in the index page, and the viewer page's button or key returns to index-page top.
Navigation: Next/Prev tap, left/right swipe, n/p key
To move to the next or prior image, tap Next or Prev, perform a left or right swipe gesture, or press keyboard keys n or p. Messages appear when navigation wraps around to the first or last image in the gallery, and some galleries may have end-of-gallery pages.
Slideshow: Auto tap, a key
To run a slideshow that advances to each next image after a preset delay, tap Auto or press keyboard key a. Repeat to stop the slideshow. Slideshows are an automatic Next with a delay between images and continue until toggled off.
Fullscreen: Full tap, f key
To open the page in temporary fullscreen mode, tap Full or press keyboard key f. Repeat to close fullscreen mode. This is a quick zoom but lasts for just one page. Some browsers have more permanent fullscreen options (e.g., F11 on Windows and Linux, shift+command+f or upper-left green button on macOS, Hide Toolbar on iOS, and icons on some Android browsers).
Image note: Note tap, up swipe, t key
To view a note describing the image where available, tap Note, perform an up swipe on the image itself, or press keyboard key t. Close the note with the popup's bottom OK button, the keyboard Enter key, or a tap anywhere outside the note. Notes remain open for further reading until closed by the user, even after navigating to the index or other images, or returning from a link.
Image info: label tap, down swipe, ? key
To view info about the image (from Exif tags, file, and display), tap the image label at top of page, perform a down swipe on the image itself, or press keyboard key ?. Close the info with the popup's bottom OK button, the keyboard Enter key, or a tap anywhere outside the info.
Raw view: image tap, . key, up swipe?
To view the image in raw mode in the host browser, tap the image itself or press the keyboard . key. This action is also triggered by an up swipe when no image notes are present. Use the browser's back action to return to the gallery, per the popup reminder message.

Building Galleries

Thumbspage is a Python command-line program distributed in source-code form. To use it to build a gallery, first download and unzip its code folder, and install any Python 3.X and its free Pillow extension. Then, run the unzipped folder's thumbspage.py script in your console (e.g., Terminal, Command Prompt, or app), providing gallery configuration options in any of the following forms:

The next sections go into more detail on gallery configuration.

Configuration Settings

The user_configs.py file resides in the program's own install folder. It defines all available configuration options as Python assignment statements (option = value) and documents their roles and values. The names assigned in this file are the options' names. Each option can also be provided as option=value arguments in the thumbspage.py command line, which override assignments to same-named options in user_configs.py.

For legacy reasons, a handful of primary options are asked at the console if their corresponding option remains set to None in user_configs.py and they are not provided as option=value arguments. These inputs all have option names in the user_configs.py file (e.g., inputThumbMaxSize); set them in that file or pass as arguments to avoid console inputs (e.g., inputThumbMaxSize=128).

As a special case, if a first argument is passed to thumbspage.py and it is not of the form option=value, it is assumed to be the pathname of the gallery's folder, where your images and configuration files reside. This can also be provided as option name inputImagesFolderPath via user_configs.py or command-line argument.

In sum, option configuration is layered as follows:

Command-line Examples

In the following example command lines, thumbspage.py may be the full pathname to the program's main script, and Windows typically spans lines with ^ or ` instead of \ and uses py or py -3 instead of python3:

Use options in user_configs.py, ask if console inputs are None:

    $ python3 thumbspage.py

Also provide the image folder's pathname as the first argument:

    $ python3 thumbspage.py folder

Also provide arguments that override user_configs.py settings:

    $ python3 thumbspage.py folder option1=value option2=value

Same as prior, in shells that support spanning lines with "\":

    $ python3 thumbspage.py folder \
            option1=value \
            option2=value

A larger example with explicit options and no console inputs:

    $ python3 ~/Downloads/thumbspage/thumbspage.py . \
            useDynamicIndexLayout=True \
            dynamicLayoutPaddingH=\'16px\' \
            inputCleanThumbsFolder=True \
            inputThumbMaxSize=128 \
            inputUseViewerPages=True \
            popupFgColor=\'wheat\' \
            popupOpacity=0.45 \
            omitIndexPageLabels=True

Provide console inputs from a file using stream redirection:

    $ python3 ../thumbspage.py mypix popupFgColor=\'#ddd\' < inputs.txt

Provide console inputs with a "here" document in Bash and others:

    $ python3 ../thumbspage.py mypix popupFgColor=\'blue\' <<-EOF
	
    	    (128,128)
		
            EOF

Configuration Files

In addition to named configuration options, you may also optionally configure thumbspage galleries by:

If used, HEADER.html and FOOTER.html contain the HTML code used above and below the thumbnails table in index pages. They are advanced tools described ahead.

ORDER.txt lists one filename per line to give an explicit image order, and NOTES.py and CAPTIONS.py contain a Python dictionary mapping image filenames to notes and labels. If provided, these files' content overrides and augments filename ordering, .note text files, and filename labels.

Whether coded in .note files or the NOTES.py dictionary, image notes may embed HTML tags and entities passed to the browser when escaped with a leading underscore. Notes are optional.

See user_configs.py and later sections of this User Guide for additional details on all of the above.

Testing and Publishing

After running thumbspage.py to build a gallery, open the image folder's generated file index.html (its default name) in your browser to view the resulting gallery. To publish a built gallery, simply install the entire image folder on the local or remote host, with a copy, zip+unzip, or upload as needed. Include the image folder's generated _thumbspage subfolder, which contains scaffolding files needed to view the gallery.

For more ideas, see the 3.0 demo's build and publish scripts.

Overview

This section introduces the basics of thumbspage's roles and operation. Read this first if you're looking for a quick summary.

Why thumbspage?

In short, this program allows you to view or display a folder of images in a web browser, using a format which is simple by design yet noticeably better than browser defaults, and does not require a web server except when viewing images online.

thumbspage turns an images folder into an easily viewed gallery. It automatically makes image thumbnails, an HTML thumbnail-links index page, and HTML image-viewer pages for all the images in a source folder, all of which can be broadly customized by content creators. The mostly static results can be viewed offline or online in any web browser.

In a theoretical sense, thumbspage is a program that builds another program: its results are a combination of HTML, CSS, and JavaScript, which are run by a browser. More tangibly, thumbspage simply creates presentation scaffolding for user-friendly views of a folder's images.

What thumbspage Does

In a bit more detail, given a folder of image files, this program generates an HTML index page in one of two flavors, with generated thumbnail links for each image in the folder. This page's links open the full-size images using either browser-native (i.e., built-in) display, or generated HTML viewer pages.

Viewer pages in turn dynamically scale the image to your display; include links for gallery navigation, automatic slideshows, and one-page fullscreen; and open image-info popups on filename clicks, and image-description popups on button taps when enabled. On mobile and PC touch screens, swipe gestures on the image trigger viewer-page actions too.

Apart from image scaling and interactive tools, the net effect is intentionally static: generated results reflect the folder's contents at build time only, but do not require a web server, and can be viewed both offline and online in any desktop or mobile browser. As such, this program can be used both for both websites and non-web use cases, including program documentation, photo sharing, and general viewing.

When run using the techniques explored ahead, the builder program skips non-image files; uses optional header and footer HTML inserts in the index page; uses text note files for any or all images in viewer pages; makes an optional bullet list for subfolders in the images folder; and creates the output index page in the images folder itself, along with a subfolder for thumbnail images and viewer pages. The resulting gallery is complete and self-contained, and ready to be viewed or published.

Using thumbspage Galleries

After running this program, you can view or publish its results in a variety of ways:

To view results
Use any web browser to open the generated index page created in your images folder (the page is named index.html by default).
To publish results
Copy the entire images folder, including its generated thumbs subfolder and index file (named _thumbspage and index.html by default, respectively).
To publish results to a remote website
Upload the entire images folder—index page, images, and thumbs subfolder—to the folder representing your gallery on your site's web-server host. Zip or otherwise bundle the folder first for convenience.

As a client example, the website that hosts thumbspage uses it for some 50 galleries today, some of which are viewable both online at the site, and offline in program download packages. For a sampling, see this site's demos. Builders can also find gallery-build pointers in thumbspage's publishing scripts, though its simple console interaction or command lines may suffice for most uses.

Latest thumbspage Features

thumbspage began as a builder of simple index pages that used generated thumbnail images for their links, but its feature set has evolved over time in response to usage experience. Among its new highlights added in recent releases:

You can read the full story on new releases ahead. Move on to the next section to start learning how to use thumbspage to view and display your photos.

Viewing Galleries

This section covers the basics of viewing the galleries which thumbspage creates. It's oriented towards gallery consumers (a.k.a. users), though creators might find its functionality overview helpful too. If you're looking for details on running the program to make galleries, though, see the builders' section.

By today's standards, thumbspage galleries are straightforward and intuitive to use. They work and may be viewed on any desktop or mobile browser, and both online and offline. No extensions must be installed in browsers to view thumbspage galleries, though JavaScript should be enabled for the best user-interface (UI) experience, and some browsers have known quirks that can impact gallery behavior (there's more on JavaScript and browsers in Viewing Tips ahead).

Once built, a thumbspage gallery consists of an index page opened initially, and one viewer page per image opened from either thumbnails on the index page, or direct page-address URLs. The next sections describe how these two page types are used.

Index Pages

Index pages are the usual entry point into a gallery. Here's one captured on desktop and mobile browsers, and its live version.

Index pages display thumbnail images, either in a fixed table which scrolls both horizontally and vertically as needed, or arranged to fit the display's size per the 2.1 update ahead. Either way, index-page thumbnails normally open the next section's larger image-viewer pages when tapped (or clicked). By default, index pages also display the image folder's basename, and a bullet-list of links that open subfolders nested in the page's folder, if any are present.

Beginning with 2.0, thumbspage index pages also usually display a floating Top button near page bottom after a scroll, much like that in this guide. Click (or tap) Top to jump to the top of the index page immediately—to read its preface or open its first image, for example. Top appears only after you scroll down far enough, so it may not show up on smaller index pages.

An index page's subfolders links may lead to supplemental info or nested galleries, and their behavior varies per usage mode. When viewing galleries online, subfolder links typically open a nested gallery's index page automatically. When viewing offline, these links open a simple directory listing, and you'll manually click nested galleries' index pages (e.g., index.html) if present. These links also open directory listings for non-gallery folders on some online servers; tap filenames to open. There's more on subfolders ahead.

While many index pages follow the preceding norm, individual galleries can also customize it with tailored header and footer content above and below the thumbnails table. They might also use thumbnails that open raw displays instead of viewer pages, may display tooltips on mouseovers, and can opt out of either floating Top buttons or subfolder bullet lists. Experiment with galleries you visit to see which options they support.

Update: as of version 2.1, thumbspage index pages may also use either a fixed or dynamic layout. By default, index pages use the original fixed layout, which always displays the same number of columns. In dynamic layout, the thumbnails table does not scroll horizontally; instead, the number of columns is chosen to match the display size, and changes when the display is resized. Dynamic layout is an option which can be enabled when a gallery is built. If you run across this alternative, you can shrink or expand your window on PCs and mobiles with popup app windows to view fewer or more columns. On mobile in general, switching device orientation has a similar effect. See the demo.

Viewer Pages

Index-page thumbnail clicks and taps by default open viewer pages (a.k.a. image-viewer pages in this doc) to display a single image. Here's one captured on desktop and mobile, along with its live version.

Viewer pages display the image's filename, the image itself, and a bottom toolbar of action buttons, and respond to swipe gestures on the image on touch screens. The image is automatically scaled to fill the window's or display's available space, and grows or shrinks in both directions with desktop-window resizes, mobile-device rotations, fullscreen toggles, and popup or split-screen app-window resizes on some mobiles. The toolbar has four to six named action items (Note and Full are optional), and scrolls horizontally to reveal buttons if needed on smaller displays. Viewer pages may display tooltips on mouseovers too; this is enabled by default when galleries are built.

Everything on a viewer page does something when tapped and images respond to swipes, as the following sections will describe.

Widget Actions

All told, there are seven or eight actions available to users on viewer pages, five of which have swipe-gesture equivalents—and two of which are invoked with display widgets instead of buttons:

Filename tap — view image-info popup
Open an info dialog describing the image. This displays the image's date of origin; date last modified; file size; and image and display dimensions (as width x height pixels). When date of origin is known, "Taken" means a camera capture, and "Digitized" implies a scan. If known, the popup also lists the origin device (e.g., camera or scanner) or software (e.g., drawing program). The info popup appears at the top of the page; scroll its text or page as needed on smaller displays, and tap its OK button—or anywhere outside the popup's window in most browsers—to close the dialog. As of 2.2, the filename-tap event is also triggered by a down swipe on the image.
Image tap — view raw display
Open the image using the underlying browser's raw display. This display is useful for a zooming in and out (e.g., with spread/pinch, or control or command with +/-), and may yield a larger image depending on browser and display size. Use the browser's back action (button or swipe) to return to the gallery's viewer page. The Full toolbar button also zooms the image in most contexts, but we have to move ahead to see how. As of 2.2, the image-tap event is also triggered by an up swipe on the image in supporting browsers when image notes are unused (see ahead).

Toolbar Actions

The remaining viewer-page actions can all be requested by tapping named toolbar buttons (or swiping equivalently), and one is optional and may be omitted when a gallery is built:

Prev — view previous image
Go to the previous image, in filename-sorted order. By design, the current image is not 'stacked' in browser history, which means it won't be revisited on a browser Back request; you'll jump immediately to where you where before the first image view. As of 2.2, Prev is also triggered by a left- or right swipe on the image.
Next — view next image
Go to the next image, in filename-sorted order. Just like Prev, the current image is not 'stacked' in browser history on Next, so it won't be revisited on a browser Back request; you won't have to retrace through every image you've viewed. The Auto button covered ahead automatically runs Next. As of 2.2, Next is also triggered by a left- or right swipe on the image.
Index — view thumbnails page
Go to the thumbnails index page of this gallery. This is usually equivalent to a browser Back request unless the gallery was entered at a specific image, except that the image-viewer page is remembered in browser history so you can return to it with a later Back.
Note — view image-description popup
Open the image's note, if one is available. As of 2.3, galleries can use notes to describe individual pictures on viewer pages. This adds a new component to galleries which choose to use it. To view an image's note, click on the toolbar's Note button, or up swipe on the image itself on a touch screen. The note appears as a popup window at the bottom of the page, and can be dismissed by tapping its OK button, or anywhere outside the popup on most browsers. Images without a note always have a line-through on their Note button so you can skip them, and notes can be scrolled vertically for smaller screens and larger notes.

Keep in mind that this feature is optional and new: Note buttons will be present and up swipes will open notes only if notes were enabled at gallery build time. If notes are unused, up swipes open raw views as in 2.2; if notes are used, you can still open raw views with an image tap. Also note that Note popups don't stay open during Auto slideshows; tap Auto to stop and read a note along the way, per the next item here.

Auto — start/stop slideshow
Toggle the automatic slideshow on or off for this gallery. Slideshows run toolbar Next operations in time-delayed mode, automatically advancing to each next image after a fixed pause that may vary per gallery (it's 5 seconds by default). Use this to step through images without manual navigation; like Next, pages you visit aren't added to browser history, so you need not retrace your slideshow path later on browser Back requests.

When active, a slideshow applies to all thumbspage viewer pages visited in a single browser tab. They stop (really, pause) when you leave a gallery's pages, and may be cancelled or restarted at any time by pressing Auto again in any viewer page. The Prev and Next toolbar buttons work during, and do not cancel, an active slideshow; use these to skip or move to images during the show. You can also use Index or your browser's Back function to pick an image from the gallery's index page at which to continue the slideshow in progress. In most contexts, a Back or any other navigation that reenters a gallery resumes a slideshow left in progress too; press Auto to cancel whenever you like (and see ahead for a rare exception on Safari).

Update: as of version 2.1, the Auto button changes to be underlined as an indicator whenever the slideshow is on, and changes back to normal text when the slideshow is off. This helps make the show's state apparent, especially when it's first started or is resumed on return from another page.

Full — open/close one-page fullscreen (optional)
Toggle a page-induced fullscreen display on platforms that support one, for this page only. When present, the Full toggle maximizes the browser window and hides all browser and platform toolbars; another tap shrinks back to normal size. Some browsers and platforms don't support this fullscreen mode (e.g., iOS), and on all those that do, the fullscreen display lasts for just the current window: any navigation to a new image page cancels fullscreen mode—including Next, Prev, and automatically moving to the next image in an Auto slideshow. This obviously limits what you can do with Full.

Because of these limitations, the Full button and feature may be omitted on a per-gallery basis (it's enabled by default). When Full is available, it provides a per-image blowup/quick-zoom option (e.g., before and after), that may be easier than raw-image zooming via image taps. Users looking for a true fullscreen experience, however, may be better served by using browsers which support a manual fullscreen that spans multiple pages, including those in thumbspage slideshows; see the next section's fullscreen tip for pointers. Note that Full may be hidden on small displays; scroll the toolbar left as needed.

Update: like Auto, the Full button changes to be underlined as of 2.1 as an indicator that its fullscreen mode is on, and resets its font when its fullscreen is cancelled, whether by Full or outside the page (e.g., with an Escape key). Unlike Auto, though, fullscreen mode is obvious, and Full's font changes are not supported on all browsers. Moreover, even where supported, Full will not change for, and will not cancel, a fullscreen mode started independently of the page; for better or worse, user-initiated and page-initiated fullscreens differ, and browsers handicap the latter in the name of security.

Swipe Actions

Beginning with version 2.2, thumbspage viewer pages respond to swipe gestures on all devices and browsers which support them. Swipes require a touch screen (update: touchpad and mousewheel swipes are also supported as of version 3.0), but they work broadly on both smartphones and Windows PCs, and in all dozen browsers tested except Internet Explorer (subject to one up swipe limitation covered ahead).

To perform a swipe, start the gesture in the image-display area for touchscreens—that is, on the image itself—in any viewer page. Touchpad and mousewheel swipes may be performed anywhere. The physical direction of the swipe depends on system settings, as noted in the 3.0 Quick Start, but the logical direction of the swipe determines its action:

Down swipe — view info popup
This gesture opens the image-info dialog at the top of the page, and is the same as tapping the filename. As noted above, close the popup by tapping its OK, or anywhere outside the popup box on most browsers.
Up swipe — view image note or raw display
This gesture invokes one of two actions, depending on how the gallery was built:

Left swipe, right swipe — view next and previous image
These gestures move forward and backward through the gallery, just like tapping the Next and Prev toolbar buttons. The direction of movement depends on both user settings and a configuration setting at gallery build time, so try a few swipes to see how they step through the galleries you view. Per the preset default, left swipe means next image (Next), and right swipe means previous image (Prev).

You can test-drive swipes on a touch-screen device by running any of the demos listed here. Where available, swipes are simply a convenient alternative to other page actions. All former widget and toolbar taps described above still work as they did in prior versions, as do browser long-presses, pinch/spread zooms, and back/forward swipes. Mouse clicks naturally still work on non-touch displays too.

Usage tip: some browsers implement back/forward swipes as an alternative to buttons. thumbspage left/right swipes won't clash with these as long as both are performed well. Be sure to trigger browser back/forward with a short flick from screen edges, and begin thumbspage swipes in the page's image display. If this is difficult, you can also do back/forward by swiping above or below the thumbspage image-display area, or simply use browser back/forward buttons.

As usual with UIs, first-hand experience is also a great way to learn how to use thumbspage galleries; browse the examples in the thumbspage package, and test-drive the live demos at thumbspage's host site for more on index- and viewer-page interaction. The next section provides more info on gallery views.

Viewing Tips

This section collects additional assorted tips for viewing thumbspage galleries. Content you'll find here:

  1. JavaScript requirement
  2. Browser and device support
  3. Enable iOS 13's Hide Toolbar for Safari
  4. Fullscreen manual options
  5. iOS Chrome may stack navigation history
  6. Viewing galleries offline on PCs
  7. Viewing galleries offline on Android
  8. Viewing galleries offline on iOS?
  9. Beware browser settings and bugs
JavaScript requirement
Although thumbspage galleries work in any unextended browser, they do require that the browser's JavaScript support be enabled if you wish to use index pages' floating Top buttons, as well as viewer pages' navigation, image scaling, info popups, notes, swipes, automatic slideshows, and one-page fullscreen display. Both types of pages still function without JavaScript, but these features are either not displayed or inoperable when JavaScript is disabled.

Because viewer pages suffer most when JavaScript is off, they give you an alert when yours is disabled; here's one on desktop and mobile. JavaScript can be misused, but is fully harmless in code that thumbspage generates itself, and is essential for the sort of interactive-UI functionality offered by thumbspage galleries. In fact, most of today's web isn't quite usable without it—for better or worse. Please turn JavaScript on for the best thumbspage experience.

Update: as of version 2.3, JavaScript is now fully required for using the viewer pages created by thumbspage. This is normal on the web today, and was already effectively required in prior versions, because images did not scale and most widgets were inoperative. 2.3 made it official, with an enhancement that renders navigation buttons no-ops without JavaScript too, leaving no usable content. For more background, see the builder's note.

Browser and device support
Short story: thumbspage galleries should work well on all browsers and devices in common use today (and a few in uncommon use too). Galleries have been explicitly verified on dozens of browsers—including multiple versions of Chrome, Firefox, Safari, Edge, Internet Explorer, and Opera, running on multiple versions of macOS, Windows, Linux, Android, and iOS. Galleries have also been verified on a range of PC and mobile devices, including displays as small as 4 inches.

Caveats: while no browsers or devices are known to be unable to display thumbspage galleries, some browsers have relevant quirks mentioned in other notes ahead; usability is naturally subject to browser and platform changes; and viewability is prone to decline with screen size (all bets are off on your watch). That said, HTML may not be a portability utopia, but thumbspage manages to make it work.

Enable iOS 13's Hide Toolbar for Safari
If you're using Safari on an iPhone, iPad, or iPod, thumbspage galleries are best viewed with iOS 13's Hide Toolbar option enabled. This option is available in the "aA" menu at the upper left of Safari's window, and is applied to all pages opened in an enabling tab, including all those in an Auto slideshow. Without this option, Safari reports sizes poorly on iOS, which makes thumbspage image-viewer windows require a scroll in landscape mode; with this option, both landscape and portrait work better, and links don't require an extra tap. Other browsers on iOS, including Chrome, don't have these issues.
Fullscreen manual options
As noted earlier, the Full button on thumbspage viewer pages is optional, because it lasts for just one page, and is supported unevenly across browsers. By contrast, many browsers offer a manual, user-initiated fullscreen mode that persists across page switches, including those of thumbspage Auto slideshows. Where available, this can be a much more useful alternative. The options for invoking a manual fullscreen are too many to cover here, but here's a quick rundown:

For additional tips and other platforms and browsers, try a web search, or consult your browser; browsers change regularly, and new fullscreen options may crop up over time. Manual and persistent fullscreen isn't available everywhere today, but it generally beats thumbspage's one-page Full where possible. You may still find thumbspage's Full useful as a quick zoom, though, especially on browsers that lack a manual option today. With any luck, those browsers will make Full fully superfluous in the not-too-distant tomorrow.

Update: on Android, the Opera web browser recently gained an amazing fullscreen mode for landscape that works much like those in desktop browsers, and spans multiple pages. For details, see this usage note at thumbspage's host site. The Opera browser is largely the same as Chrome under the hood, and runs thumbspage galleries just as well—and arguably better with its landscape fullscreen. Yet another reason to consider parting with the herd on Android.

(Defunct) iOS Chrome may stack navigation history
thumbspage image-viewer pages are not normally stacked (i.e., remembered) in browser history as you—or a slideshow you started—navigate through galleries. This by design, because it makes browser Back operations return to the viewer pages' entry point immediately, instead of stepping back though each image viewed. This may not work in some versions of Chrome on iOS, unfortunately, due to a bug in that browser. That bug appears to have been fixed in Chrome 83 (or earlier), but was known to still be broken as of Chrome 75. If your Chrome stacks pages, either retrace pages as needed for that browser's Back, or use any other iOS browser to view thumbspage galleries.
Viewing galleries offline on PCs
thumbspage bills its galleries as viewable both online (at a website) and offline (on your device). In more detail, online mode works universally on all devices, and offline is trivial on PCs (which means Windows, Linux, and macOS here)—a click in a file-explorer window (e.g., Finder or Explorer) normally suffices to open a gallery in your default browser, and right-clicks, browser Open functions, and explicit file:// URLs offer more options. On mobile devices, however, offline viewing isn't always as seamless, but you'll have to move on to the next two notes for the Android and iOS offline stories. macOS Safari users: see also the caveat ahead for the rare use case of browser Back returns to offline galleries.
Viewing galleries offline on Android
(TL;DR: jump to the latest update for new file-explorer options.) On some unrooted Androids, you may have trouble viewing a gallery stored locally on the device: the index page may open in a file explorer, but its thumbnails and viewer pages won't. This happens mostly in Chrome on newer Androids, and seems related to that platform's push to tighter permissions and content:// URIs. While these may be spun as security measures, that argument has been tiredly used for many an Android breakage.

thumbspage galleries are known to work offline on Androids Nougat, Oreo, Pie, and 10, but its releases and devices vary too widely to give universal advice here. If your offline gallery fails, try the following work-arounds that have proved successful in some contexts:

Especially on newer Androids, also make sure the browser has permission to access your files in storage. Firefox, for example, may require this on Android 10. Try Settings/Apps and navigate to storage permissions, or similar on your device. This has grown more crucial as later Androids have moved to lock down storage to app-specific sandboxes.

If you're technically inclined, you might also try running a web-server app on your device and viewing your gallery on localhost or a dedicated port number; this is wholly untested (but arguably awesome). Caveat: the upcoming Android 11 will clamp permissions down further (read the latest edicts here), but its impact on browser apps remains to be seen.

Update: for recent findings on both local-file views and running web-server apps on Android, see the off-page coverage here, which is part of an Android 11 review. In short, you can run a web server on Android, but your functionality may be limited and your disconnections many. Android 11 has also narrowed your options for local-file views in browsers, in the name of a security rationale; inoperable phones may be secure, but they're also inoperable.

Update: the thumbspage team recently discovered another route to offline viewing on Android. On Android 11, simply copy your content into the browser's own sandboxed folder, using a file explorer that has permission to do so (Solid Explorer and Cx File Explorer do at this writing). Then, use that folder's local path in a file:// URL in the browser to view offline. For example, copy content to these locations for Chrome and Opera (alas, this won't work for Firefox on 11, because it strips the file://):

file:///storage/emulated/0/Android/data/com.android.chrome/your-folder-and-file-here
file:///storage/emulated/0/Android/data/com.opera.browser/your-folder-and-file-here
This works for Chrome on Android 10 too, but isn't required for Opera or Firefox on 10, where they have full access to arbitrary storage paths (unlike both Chrome on 10, and all browsers on 11). This isn't the same as arbitrary file access, of course; you're limited to files dropped into a browser's folder. This is also an arguably terrible idea: your content in the sandbox folder will be deleted if you uninstall the browser, and is prone to being nuked if the browser ever resets its own folder. Hacker beware!

Update: in late 2021, some Android file explorers now provide seemingly heroic work-arounds on Android 11 that allow you to use a browser to view web pages stored locally on your phone—including thumbspage galleries. For example, among file-explorer apps tested:

Thus, your first step when trying to view locally stored thumbspage galleries on Android 11 and later today is to simply try opening them in a file-explorer app to see if they are supported automatically. For more details on the constantly evolving struggle between Android permissions and file explorers, see also the updates here, here, and here.

Viewing galleries offline on iOS?
On unrooted Apple mobiles, iOS 13's enhanced Files app allows you to open files both on USB drives and copied to internal storage. This lets you view a gallery's pages, but doesn't open a browser. Instead, it runs a stripped-down quick-view that lacks JavaScript and shows just the top-level page's text, not any images it embeds. The net effect is much like recent Android Chromes of the preceding note, and your most direct recourse may be an online (or local network) upload. While there may be additional iOS options beyond thumbspage's testing budget, Apple has historically been more closed than Android (and its appetite for control seems only to be growing).
Beware browser settings and bugs
Some browser settings that may appear harmless can adversely impact thumbspage galleries. The native (a.k.a. raw) image display of some versions of Android Chrome, for example, may initially render some images weirdly large in portrait orientation, but if and only if the seemingly unrelated Force enable zoom is selected in Accessibility Settings. The image-tap raw displays of thumbspage viewer pages trigger this effect, but do not cause it—it also happens when visiting images' URLs directly, outside gallery pages. There's more on this issue in search results, while they last; its impact is broad, but likely to be reversed soon.

Nor is this an isolated case. As another example, the thumbspage team recently found and reported a settings-related bug in 2020's Android Firefox—though not thumbspage specific, this browser sometimes leaves an odd blank strip at the bottom of thumbspage viewer pages if you enable its "Scroll to hide toolbar" option (more details here). Thumbspage's host site also reported a bug in version 53 of Android Opera—though it does not impact thumbspage galleries (and was fixed in version 60), this browser strangely truncated the remainder of a page at a /* character sequence in text formatted with <pre>.

At the end of the day, thumbspage is completely dependent on browsers which change frequently and arbitrarily, and have an unfortunate history of fragility (indeed, at times it seems a website could be laid low by a good sneeze). For best results, clear settings that cause issues on Android, use similarly obscure browser behavioral switches with care, and try other browsers as a last resort when browser bugs—and enhancements—break your viewing experience.

For more tips on using thumbspage galleries, viewers are also encouraged to browse the rest of this document; although it's focused on gallery builds from here on, you can also find usage details along the way.

Building Galleries

This section is meant for gallery creators, who run thumbspage to build new galleries. It describes thumbspage install requirements, inputs and results, customization options, and other operational details. It's also a comprehensive tutorial that doesn't assume you are already a command-line wizard—which means more advanced readers may want to skim parts useful to others. If you're looking for info on how to use galleries, try the viewers' section first.

Examples: if you enjoy learning by example, you can also study the thumbspage demo sites online here and here for sparse but fast tutorials. These sites list their run logs, and use custom headers and settings which you don't need to code if the defaults work for your galleries.

Installs and Platforms

This section covers the basic logistics of using the thumbspage program to build galleries. The pages of the galleries it builds work on all browsers and platforms and require no extra installs or infrastructure, as covered earlier.

thumbspage itself is a Python program that runs on all major platforms, and is provided in source-code form which you run with your local Python. To install the program, download its zipfile from the Download section of the following web page and unzip it on your computer:

learning-python.com/thumbspage.html
The thumbspage program also requires installs of Python 3.X (any X) to run its source code, plus the third-party Pillow (a.k.a. PIL) image library to extend the installed Python 3.X with image-processing tools. If they're not already present, fetch and install both these items from the following sites, respectively (or search the web for other links):
www.python.org/downloads/
pypi.python.org/pypi/Pillow

thumbspage can be run to build galleries on any platform that runs Python 3.X and Pillow, and has the required folder and file access permissions. For example, this program has been verified to run on Windows, macOS, Linux, and Android. The latter has unique requirements and permission rules; see the notebox below for usage on Android, as well as the similarly constrained iOS. For a related Pillow install pointer, see also this page.

As discussed ahead, as of version 1.7 thumbspage also uses the pure-Python and third-party piexif library to update image Exif tags, but this library's code is included and shipped with thumbspage itself on all platforms, and does not require a separate install.

A note for programmers: Pillow is used from Python for thumbnail generation, image rotation, and some Exif-tag processing—which all occur at gallery-build (i.e., program-run) time. Images are scaled at image-display time instead by JavaScript code in generated viewer pages—which mix HTML, CSS, and JavaScript in a tangled and browser-specific morass that is the norm for web development today. The stew manages to work well anyhow.

thumbspage on Mobile

thumbspage galleries can be both viewed and built on mobile devices. This guide often focuses on the mobile portability of generated pages viewed, but it's also possible to run the program itself on your Android smartphone or tablet from a Python-aware app. For instance, thumbspage galleries can be built in the Termux app, after running both of the following commands (more details via search or here, though the -y suggested at the latter isn't recommended—it skips asking if you wish to proceed):

pkg install python ndk-sysroot clang make libjpeg-turbo
pip install Pillow

After this, thumbspage command lines work in Termux the same as elsewhere. You can also launch thumbspage command lines on Android in Pydroid 3, after running the same pip command in its Terminal or using its Pip GUI, and other Python apps may provide additional options. To sample the flavor of thumbspage builds in Termux, check out the Android demos here, here, and here, plus the console log here.

Caveats: keyboards naturally boost command-line usability on cramped smartphones. Android also imposes proprietary access rules which limit the folders available to your Python app—and hence thumbspage; for more on its access rules which are beyond this guide's scope, see this doc. thumbspage may run on iOS too (e.g., the Pythonista app bundles a version of Pillow), but this is untested, and iOS's access rules have historically been tighter than Android's.

Running thumbspage

Once you've installed thumbspage and its required tools per the preceding section, you're ready to start turning your image folders into galleries. This section demonstrates how to run thumbspage on your computer. It also goes over command-line basics for users new to the technique.

Usage Example

For a basic launch of thumbspage, run script thumbspage.py from a command line with no command-line arguments. It can be run from a console (e.g., Terminal on macOS and Linux, Command Prompt on Windows, and whatever qualifies as a command shell in Android apps); and after opening its file in most Python IDEs (e.g., PyEdit and IDLE).

thumbspage's main options are selected with five console replies, or their enter-key defaults, on each run. The following example session gives user inputs in bold font. In its prompts, inputs are described in [], and defaults for empty replies are given in () (Windows users: be sure to use py -3 at the start of your command line, \ instead of / in your pathnames, and a C: or other drive letter if needed):

/.../content$ python3 /MY-STUFF/Code/thumbspage/thumbspage.py 
Images folder path [. or dir] (enter=.)? trnpix
Clean thumbs folder [y or n] (enter=y)? y
Thumbs per row [int] (enter=4)? 
Thumb max size [x, y] (enter=(100, 100))? 
Use image-viewer pages [y or n] (enter=y)? y
Running
Cleaning: trnpix/_thumbspage/1996 First Pybook.png
Cleaning: trnpix/_thumbspage/1996 First Pybook.png.html
...
Skipping: .DS_Store
Making thumbnail: trnpix/_thumbspage/1996 First Pybook.png
Making thumbnail: trnpix/_thumbspage/1998 Puertorico 1.jpg
...
Skipping: _cut
Skipping: _HOW.txt
...
Generating thumbnails index page
Generating view page for: 1996-first-pybook.png
Generating view page for: 1998-puertorico-1.jpg
...
Finished: see the results in the images folder, "trnpix".

Prompts and Replies

This section documents the input replies in the preceding usage example, numbering them from the first ? prompt to the last. As we'll see in the next section, the first of these can now be provided with a command-line argument instead; this bumps the others up in the list, but the options work the same either way. Here are the parameters you'll input to run thumbspage:

Reply #1: images folder
This is where you specify the source-image folder, which is also where results will appear. This reply accepts an absolute or relative folder pathname. For example, entering just folder means that folder in the directory where the script is being run, and /folder/folder and C:\folder\folder denote absolute paths to your image folder on Unix and Windows, respectively.

Special cases: a solitary . here means the directory where the script is being run, which is also the default for an empty reply (i.e., pressing your enter key only). You can also use other path syntax such as two dots for one level up (e.g., ../folder is a sibling); see the pathname primer ahead if you're new to such things. Tip: if you name a folder which has no images, you'll make an index page with a subfolder list.

Reply #2: clean first
You should generally opt to clean (i.e., empty) the thumbs folder first with a positive response for reply #2, unless images have only been added to the image folder (in which case cleaning means remaking old thumbs, but still works in any event). There's more on this option in the building tips ahead. Note this and all the following replies are not requested if you're building an index page for an imageless folder.
Reply #3: row size
Replies #3 and #4 allow you to tailor index-page thumbnails on each run. Additional thumbnail enhancements that may span runs are available as configuration settings described ahead.

For reply #3, give the number of thumbs you want to display in each row on the index page. The thumbs table automatically expands and shrinks with the page, and scrolls both horizontally and vertically where needed. Note that this input is not requested if you opt to use 2.1's new dynamic index-page layout alternative, because this layout determines the number of columns automatically from page size.

Reply #4: thumb size
For reply #4, give the requested pixel size of all thumbnails in the gallery. Enter two numbers separated by a comma for width and height (in that order), with optional spaces and enclosing parentheses. thumbs size input is a maximum area for all thumbs: thumbspage creates thumbnails no larger than this that retain their original aspect ratio. For instance, an input 100,100 makes thumbs 100x100 pixels large, but either side may be rendered less than 100 large if needed to avoid distortion. There's more on what that actually means in the sidebar at the end of this section.

Exception: as of version 2.3, thumb sizes provided as configs by file or argument can now give a single integer instead of a tuple, if both sizes are the same. Sizes input at the console, however, must still be 2-tuples as described here. See 2.3's update for details.

Reply #5: viewer pages
Finally, you should generally elect to use image-viewer pages with a positive response for reply #5, unless they don't work well in your use case. These pages have matured much since their introduction, and have no apparent downsides today. There's more on this option in the building tips ahead.

If you change your mind or make a mistake while inputting replies: you can cancel a run by typing a break or EOF key sequence (e.g., hold control and type a c or d) at any prompt, and thumbspage reports input errors nicely as demonstrated in this console log. For more examples of console runs on various platforms, see the logs folder.

Other Usage Modes

Caution: using precoded console inputs via stream redirection or "here" documents as described in this section is now discouraged because inputs may change—and did in 3.0, which made dynamic index layout the preset default, reducing the number of inputs by one. To avoid build-script changes in the future, instead pass input options as setting=value command-line arguments, along with other per-build configs. See the updates ahead and the full coverage here and here.

Besides the basic console interaction of the prior section, thumbspage also allows you to pass in the folder name as a sole command-line argument instead of a prompt reply. This allows you to use shell auto-completion on long folder names, though it's probably more useful in a console window than an IDE. Folder argument or not, you can also automate a launch by using command-line < syntax to provide canned input parameters in a text file, one per line (technically, by redirecting the stdin stream). These options yield at least three ways to start the program:

$ python3 thumbspage.py
Images folder path [. or dir] (enter=.)? trnpix
...4 other parameters prompted from input...

$ python3 thumbspage.py trnpix
...4 other parameters prompted from input...

$ python3 thumbspage.py < inputs.txt

In the last of these modes, parameters in the input file inputs.txt would like look the following; use an empty line to accept a prompt's default, and omit the first line if you provide the folder name as an argument in the command line instead:

trnpix
y
4

y

Naturally, you can combine all these with shell syntax for pipes and output redirection (| and > file). For example, the following Unix session both sends input parameters to the script from one file, and saves its output to another; it also assumes shell variable $C has been set to name the folder where you unzip programs like thumbspage, and opts for 128-pixel thumbnails, 3 per row:

$ cat inputs.txt
y
3
128, 128
y

$ python3 $C/thumbspage/thumbspage.py trnpix < inputs.txt > report.txt
$ more report.txt
...output here...

Finally, on Unix systems—and Windows systems that have Unix subsystems or similar tools—you can also provide console inputs immediately following a command line, by using "here documents" of the sort available in Bash and other Unix shells. Using this in a script file allows you to code canned input parameters in the script itself, without having to juggle a separate file. The following demos the idea, but see your shell's docs for more details if needed; in short, it assumes $C is your install folder again, and provides canned inputs as tabbed lines between EOF markers:

$ cat generate.sh
#!/bin/bash

python3 $C/thumbspage/thumbspage.py trnpix <<-EOF
		
	2
	128, 128
	
	EOF

$ bash generate.sh     # or just "generate.sh" if it's made executable via chmod
...output here...

Fine print: use just <<EOF and omit tabs if your shell requires it, and don't expect a 2> /dev/null to suppress input prompts here. The latter won't work, because Python's input() function prompts to stdout (well, often; this is inconsistent, and an open bug). The tagpix program supports prompt drops this way, but only because it uses a custom input() that prompts to stderr. Such redirects are dodgy in any event; messages for uncaught errors, including Python exceptions, may also be lost in the bargain.

You can catch the last of these ideas in action in the shell and Python scripts here, here, and here, used to automatically generate thumbspage's example galleries. thumbspage's full set of build scripts here may also provide pointers for more advanced automated builds, including automatic zips and uploads for external thumbspage clients. Although thumbspage's basic console interaction covered above should suffice for many use cases, automating its launches is straightforward, and may be necessary when thumbspage is used as a nested tool in a larger build system.

For more background on the shell techniques shown here, try the off-site overviews of streams, redirection, variables, and here docs. For more thumbspage usage examples, browse its examples folder. The console input prompts and arguments we've met in this section are really just the first level of options in thumbspage. The sections Customization and Building Tips that follow cover additional configuration options and usage details. First, the next section explores more basics for users new to running programs from command lines.

Update: thumbspage 1.7 added the optional folder-name command-line argument. To better reflect this, 1.7 also moved folder name to be the first prompt when not provided on the command line; this invalidates some older session logs where folder name was asked later, but the difference is trivial. 2.0 added nicer input-error reporting, replacing exception tracebacks. 2.1 omits the thumbs-per-row input when dynamic layout is chosen, because the input is moot in this mode, and omits all inputs but the first as irrelevant for imageless folders.

Update: thumbspage 2.2 added optional command-line config arguments, of the form setting=value. When used, these arguments are coded in the command line after the optional folder path, and override same-named settings in the configs file. With this extension, thumbspage command lines now take the following general form:

python3 thumbspage.py imagefolder? setting=value setting=value...

For full coverage of this feature, see the 2.2 release note.

Update: thumbspage 2.3 added new config settings that can be used to override console inputs. When provided, in the config file or command-line arguments, input values are taken from the settings, and no input is requested at the console's stdin. For example, a command line of the following form overrides two console inputs with arguments:

python3 thumbspage.py imagefolder inputCleanThumbsFolder=True inputThumbsPerRow=4

This provides are portable and uniform alternative to the shell redirect and here-document techniques described in this section. For more details, see the 2.3 release note and its command examples. As noted above, 2.3 also allows thumbs maximum size to be provided as a single integer instead of a tuple, when given by configs; see 2.3's note.

A Brief Primer on Pathnames

Because thumbspage is run from a command line, you need to know the basics of folder pathnames in the console realm. Luckily, this is much simpler than it may sound; as noted, the pathname you input at prompt #1 can be either:

For instance, when running thumbspage via command lines, you can cd (change directory) to the folder containing your source image folder, and give a folder path relative to where you are working:

$ cd /MY-STUFF/camerauploads
$ python3 /Code/thumbspage/thumbspage.py 
Images folder path [. or dir] (enter=.)? imagefolderhere
Or, run the program anywhere and give an absolute path to your images folder:
$ python3 /Code/thumbspage/thumbspage.py 
Images folder path [. or dir] (enter=.)? /MY-STUFF/camerauploads/imagefolderhere

Absolute paths are generally required when running thumbspage from an IDE such as PyEdit, if they run code in the program's folder. Also see your file explorer's options for copy/paste of a pathname to which you've navigated; it can often avoid having to type a long pathname at thumbspage prompts.

As you might expect, the thumbspage.py script's path in console command lines can be relative or absolute too, depending on your console's current directory. For instance, py -3 thumbspage.py suffices to start the program on Windows if run in the thumbspage install folder, though your images folder will reside elsewhere—and may be relative or absolute:

> cd thumbspage-install-folder
> py -3 thumbspage.py 
Images folder path [. or dir] (enter=.)? C:\MY-STUFF\camerauploads\imagefolderhere

If you'd like more background on command-line use, you'll find both online and brick-and-mortar resources that go into more detail. Here, the next section moves on to show you how to make your galleries more unique, after a brief technical sidebar.

More on Thumbnail Size Inputs

For console prompt #4, thumbnails sizes are input as a pair of numeric pixel dimensions, (width, height), where parentheses and blank spaces are optional. The underlying Pillow imaging library always adjusts your inputs as needed to preserve the original image's aspect ratio, instead of warping images.

Without getting into code, here are a few examples of how this works; thumbnail sizes input on the left of => are automatically changed to sizes used on the right:

For an original image of size 100w x 50h (wider):
    (300, 100) => (200, 100)
    (100, 300) => (100, 50)
    (50,  50)  => (50,  25)
    (100, 100) => (100, 50)
    (300, 300) => (300, 150)

For an original image of size 50w x 100h (higher):
    (300, 100) => (50,  100)
    (100, 300) => (100, 200)
    (50,  50)  => (25,  50)
    (100, 100) => (50, 100)
    (300, 300) => (150, 300)

For an original image of size 100w x 100h (square):
    (300, 100) => (100, 100)
    (100, 300) => (100, 100)
    (50,  50)  => (50,  50)
    (100, 100) => (100, 100)
    (300, 300) => (300, 300)

You can see more results and experiment with this on your own using this script. In short, input dimensions you provide are essentially maximums: they define an area in which to scale thumbs; they are only ever decreased to match original images; and one may be adjusted down to keep the aspect ratio the same as the original and avoid distorting the image.

If all that makes your brain hurt, remember this much: providing square target dimensions (with the same width and height) seems the simplest path; the common value will be the maximum for both dimensions of all thumbs in a gallery. See also 2.3's update which allows giving thumb size as a single integer in configs, when sizes are square.

Customization

The most common thumbspage customization options are available as console inputs on each run, as described in the preceding section. This section covers additional customization options enabled by file edits.

User Configurations File

A set of additional customizations are available as Python settings in file user_configs.py. See that file for its options, documentation on their roles, and their preset values. As examples, that file defines Unicode encodings; gives the names of the generated index page and thumbs folder; turns subfolder-link lists on or off; as of 1.5, configures most colors; and as of 1.6, allows images to expand beyond actual sizes, and users to control auto-rotation of images. Versions 1.7 and later add numerous options you'll generally find later in the configs file.

Updates: in addition to the configs file, thumbspage 2.2 supports config command-line arguments, of the form setting=value. When used, these arguments override same-named settings in the configs file, and provide an alternative and simpler way to customize settings that may vary per gallery build. For more on this feature, see the 2.2 release note.

Header and Footer Insert Files

For more custom behavior, add unique HTML code to the top and bottom of the index page by placing it in files named HEADER.html and FOOTER.html, respectively, and storing these files in the images folder alongside your images. You can use one, both, or neither of these files; if not present, generic HTML and text is automatically generated in the index page around the thumbs table. For details on how to code these files, see the demos in folder examples/ here. In brief:

HEADER.html
Provides all of the page's HTML code up to the generated thumbnails table (or Top button or subfolder links, if used). This can be useful for adding page-specific content. For instance, header text can be used to describe the images on the page and provide related links, as in this example. Custom headers naturally assume some knowledge of HTML coding, but need not be complex, and can follow boilerplate examples (tip: generate a default index page for header code to start with). Here are the fine points on coding a header insert file of your own:

FOOTER.html
Provides the remainder of the page's HTML following the generated thumbnails table. It should add any post-table content and close the page with both </body> and </html>. For example, footer content might include navigation-toolbar links, or informational text; see both links for examples.

Subtlety: galleries which both use a custom footer and enable a floating Top button for the index page may also need to allow for extra end-of-page blank space in the footer's code to prevent the button from covering final non-fixed content; see the version 2.0 note ahead.

More Header Options

The generated thumbnail index table's code is self-contained, and requires no support code in a custom header. Conversely, a custom HEADER.html file can use CSS style code to alter the thumbs table in ways not supported by basic user settings (e.g., to tailor index-table font). The way you'll do this depends on the index-page layout model chosen:

For an example of this technique in action, see the online demo site here.

Beginning with 2.0, it's also possible to code scripts that replace an HTML comment automatically added to the <head> of default index headers and precoded in viewer pages for this purpose. See this note ahead for more details, as well as this script for an example that leverages this hook to insert analytics code in generated index pages prior to uploads. More generally, this lets programmers add arbitrarily custom code to default index-page headers, and may avoid custom headers in some use cases.

Viewer-Page Template File

As of version 1.6, viewer pages can also be changed arbitrarily by editing the template file template-viewpage.html in this program's install folder (use "view source" in your browser to see its code). For example, such edits might add site icons, analytics code, or navigation widgets specific to your usage or site. Edit with care (this file's code is fragile!) and rerun thumbspage to use your customized template.

Starting in 2.0, you can also customize viewer pages by programmatically replacing the automatic <head> comments noted in the prior section and described here. Though this requires some programming skills, it is probably a safer option than changing the viewer template in place, especially if you ever upgrade to a new release (your edits won't be overwritten by an unzip).

Floating-Top Template File

As of version 2.0, you can also customize the optional floating Top button of index pages, by editing the new source-code file template-floatingtop.html, which host the button's implementation code. This isn't normally necessary, because nearly every property of the Top button can be customized with settings in the configs file, per the 2.0 change note.

Image Note Files

As of version 2.3, you can optionally provide plain-text note files for any or all of your image files, to provide descriptions or narration for the images in your gallery. These notes are displayed as a popup in viewer pages when users tap the tollbar Note button, or up swipe on the image on touch displays.

When present, note files appear alongside images in the images folder, and are named with a .note extension following the corresponding image file's name. For instance the note for an image file photo1.jpg should be named photo1.jpg.note. Note files may contain any Unicode text, including emojis, though HTML code is shown verbatim (links won't work). Lines are collapsed into paragraphs, with the exception that a blank line coded as two adjacent line breaks (i.e., \n\n) is taken to be a paragraph separator, and renders as a blank line in the popup.

This feature may be disabled, and Note buttons and their up swipe appears only if this is enabled and at least on note file is present in the images folder. For a demo of notes in action, see this gallery. For more details on notes, see the 2.3 release note. Related: if you use notes, you may also be interested in 2.3's thumbs-only index pages.

Summary: thumbspage Folders

To tie together the ideas covered so far, the following sketches the structure of an images folder processed by thumbspage, with generated parts in bold font and default names and behavior applied:

Your image source folder/
    Your image files...
    Optional image.note files...
    Optional HEADER.html
    Optional FOOTER.html
    index.html
    _thumbspage/
        Thumbnail-image files...
        Viewer-page files...

Open the generated index.html file to view the thumbspage gallery, and package the entire images source folder to distribute. Exceptions: HEADER.html, FOOTER.html, and image .note files, if used, are required at gallery build time only, and need not be present when a gallery is viewed. This follows from the fact that header and footer contents are embedded in generated index pages, and image notes are embedded in generated viewer pages. Shipping these files to content consumers is optional.

You can view raw examples of generated index and viewer pages and _thumbspage/ folders online here, here, and here, and their live renditions here. In addition to the images-folder content sketched above, some files in the thumbspage install (unzipped) folder are available for user customizations:

thumbspage install folder/
    Implementation files...
    user_configs.py
    template-viewpage.html
    template-floatingtop.html
Edit user_configs.py and the HTML template files as you like for your galleries. Not shown above, your image folders may also contain subfolders that might show up in bullet lists on the index page; but to explore special cases like this we have to move on to the next section.

Updates: in addition to the files and options covered in this section, version 3.0 adds a new program-folder template file for dark mode, template-autothemes.html, along with the optional image-folder config files ORDER.txt, NOTES.py, and CAPTIONS.py, which give image ordering, notes, and labels, respectively. For more detail, see the 3.0 Quick Start and release notes as well as docs in the user_configs.py file.

Building Tips

This section collects assorted pointers for thumbspage gallery builders. Though arguably random, it covers some of the most common issues and border cases that may arise when using the program. Notes you'll find here (be sure to also browse Version History for tips omitted in this section):

  1. Viewer pages (or not)
  2. Image filenames text and length
  3. Supported image types
  4. Other image-folder content
  5. Subfolder bullet lists
  6. Linking to results with URLs
  7. Tilted-image rotation
  8. Cleaning the thumbs folder
  9. Thumbs-folder name
  10. Extra-files overhead
  11. A word on image size and speed
Viewer pages (or not)
The image-viewer pages added in version 1.5 are optional. If subpar in your use case, they can be disabled via the last console reply (see Running thumbspage above) to use the former browser-native display. As of 1.6, though, these pages scale displayed images well everywhere: images grow and shrink with the window or display, without changing their aspect ratio, distorting content, or overflowing their bounds. As a fallback (and for better zooms in some contexts), users may also click these pages' "Raw" links for browser-native view.

Update: as of version 1.7, viewer pages are even more functional—with info-dialog popups on filename taps, and easier Raw-display access via image clicks—and repair some former large-font issues (see the release notes). These pages are now broadly recommended.

Update: as of version 2.0, "Raw" button taps are now fully replaced by image taps, and new "Auto" and "Full" buttons provide slideshows and one-page fullscreen, respectively; see 2.0's release notes, and use viewer pages.

Image filenames text and length
Although thumbspage properly escapes and handles arbitrary image filenames, those in your galleries should generally avoid characters illegal on some filesystems (e.g., "), especially if they are to be viewed on multiple devices. By contrast, galleries uploaded to a web server need satisfy only their server's filename rules.

Also note that because filenames used on labels are not line-wrapped, their width largely determines column spacing on the index page. As a rule of thumb (pun intended...), use shorter filenames for narrower columns.

Update: on a related point, version 2.0 now wraps or scrolls absurdly long file and folder names; see the release note.

Supported image types
Images in the source folder are detected by MIME type (i.e., filename extension). All files there with an image MIME type are considered an image by thumbspage and included in the generated gallery, whether they have camera-oriented Exif tags or not. For example, JPEGs, PNGs, GIFs, BMPs, TIFFs, and more all qualify.

That said, thumbspage galleries can display only image types supported by both the Pillow library used to build their thumbnails, and the web browsers used to view their pages. While Pillow happily creates thumbnails for nearly every image type under the sun (with some exceptions: see the HEIC update ahead), web browsers are much more limited.

TIFFs, for example, yield correct thumbnails and display well in Safari, Edge, and Internet Explorer, but cannot be displayed by Chrome or Firefox. The upstart WebP format similarly is supported by Pillow (and hence by thumbspage builds); but support is an add-on in some versions of Edge and still growing in Safari (and hence in thumbspage views). See this shot for current results in Chrome (top left), Firefox, and Safari (right).

Because of these constraints, the support story today reads as follows:

Some browsers may ask to auto-open some exotic image types in another program, but this isn't the same as in-page support. If your TIFFs (or other) images don't display in a browser you use, your best recourse is to convert them to a more widely supported format for use in thumbspage, such as PNG or JPEG. A "Save as" in your local image editor will generally suffice. For a demo of common supported image types, see examples/mixedtypes. For more on browser image support, try this page or this search.

Also note that the above pertains only to image display. Support for image metadata—of the Exif-tag sort displayed by info popups—varies by image type too. JPEGs are generally tag rich, for example, but PNGs, TIFFs, and WebPs may be more spotty, and image libraries may not recognize newer formats. thumbspage collects metadata where possible, and omits it elsewhere.

One browser-specific caution: a somewhat dated Safari (2015's version 9) on macOS has been seen to crash altogether when trying to display a PBM in the mixed-types demo pages, for unknown reasons that are well beyond the scope of the thumbspage project. Safari updates, image conversions, and other browsers are the suggested remedies.

Update: in 2021, support for Apple's HEIF/HEIC image format common on iPhones is still not present in either stock Pillow or Python's mimetypes module (the latter means it won't appear in galleries at all), but it might be usable in thumbspage with a third-party library and programming solutions. Barring such extensions, your best bets may be to convert these images to JPEGs, or change your Camera or Photos settings to save or transfer in JPEG format, respectively. Try searches here and here for pointers.

Other image-folder content
Because images in the source folder are detected by their MIME types (per the prior note), all non-image items in the source folder are simply ignored. Hence, it's safe to include arbitrary files and folders in the images folder; apart from the next note's special case, all unrelated items, including Unix hidden files, are always skipped and ignored by thumbspage.

Update: beginning in 2.3, files in the images folder with a .note extension are special, and provide image notes displayed in the UI when present; see the 2.3 coverage. Technically, header and footer files are similarly special.

Subfolder bullet lists
As a special content case, subfolders in the images folder will show up near the top of the index page in a subfolder-links bullet list, if the subfolders feature is enabled in the configurations file. This allows your pages to provide access to nested content—including details about the folder, or image folders within image folders—if useful in your galleries. For example, you might use this to describe a gallery's images, instead of text in a custom header file.

Exception: subfolders named with a leading _ or . character are not included in the bullet list; the former is considered developer private per Python convention, and the latter is hidden per Unix convention. See version 1.1's note ahead for more subfolders lists in general; version 1.7's update to skip .* subfolders too; and version 2.1's customizable space between subfolder-list items.

Linking to results with URLs
When referencing this program's results in hyperlink URLs, note that links to generated folders of forms .../folder and .../folder/ work only when a web server is present. Use the more complete and explicit form ...folder/index.html to also (or only) view results offline. To link to individual images, use either their image-file or viewer-page URLs; the latter gives access to the gallery and its formatting. In sum:
...folder/index.html                   # the index page
...folder/image.jpg                    # an image itself
...folder/_thumbspage/image.jpg.html   # an image's viewer page
Tilted-image rotation
As of version 1.6, any images that are "tilted" (stored by cameras and smartphones with orientation tags, and content shifted to a side) are by default automatically rotated to display right-side up—both the image itself and its thumbnail. This works for all images with usable Exif orientation tags (see the standard), which generally includes all JPEG photos created by recent devices, and as of version 1.7 propagates Exif metadata tags to the rotated image.

Because rotation changes the source image file in-place for browser inline display, the original image is by default first saved with a .original filename extension in the source folder as a backup copy. See user_configs.py for settings that allow users to disable this feature and/or its backups; the included simple utility script that restores all originals from backups; and 1.6 release notes and later updates to them in Version History ahead for more background (version 2.1, for example, adds deletion of embedded thumbnails on rotations).

Cleaning the thumbs folder
thumbspage always regenerates viewer pages for each image on each run, so they correctly reflect your image set. For speed, though, image thumbnails created in prior runs are reused if present in the thumbs subfolder: new versions are not created, even if images have changed. Hence, you should always select the "Clean thumbs folder" console option in reply #2 (see Running thumbspage earlier) to force regeneration of thumbnails if any images have been changed or removed.

Conversely, folder cleaning is not required if images are only added to the images folder—thumbnails will be made for new images only, and thumbs for previously added images will be retained. This can save substantial time when extending large image folders. But when in doubt, clean; this script's work is done once, before any views.

Thumbs-folder name
The nested folder used to store generated thumbnails and viewer pages is named _thumbspage by default, in user_configs.py. It is not named with a leading . character to make it a Unix hidden file, because hidden files are rude (you should really see what programs do to your computer), and may be skipped by some compression and backup programs (e.g., see ziptools and Mergeall at learning-python.com). The default name can be freely changed to be hidden if . tradeoffs are acceptable in your usage (but you didn't hear that here).
Extra-files overhead
This script adds two files for every one source image (thumbnail and viewer page). That's negligible in most use cases, but may become significant in archives with very many files (10k images means 20k extra files). Incremental backup tools like Mergeall, for instance, may need to analyze and skip all files added. If this impacts your usage, thumbs folders can be zipped into single file archives where appropriate and needed.
A word on image size and speed
The trade-off between image quality and download speed is a classic dilemma on the web, and remains a peripheral factor when using image-focused programs like thumbspage. While this factor is not unique to thumbspage, and applies only to galleries published live on the web, this note provides a few tips on the subject.

The issue: when published online, thumbspage's thumbnail-index pages load quickly, but its image-viewer pages must download images in full before scaling them to browser windows. As a consequence, some large images in thumbspage galleries may download slowly on some servers or clients. In early 2020, for example, large (e.g., 2-6M) image transfers on the business-hosting server that houses thumbspage were usually very quick (e.g., 2-3 seconds), but sporadically throttled down to an outright crawl (e.g., 20-30 seconds). It's unclear if this speed hit was due to traffic on the server itself or the broadband and cellular client networks accessing it, but similar delays may occur in other contexts. Such delays can obviously be discouraging to site visitors, and posting large images in general might even be rude to users with limited or metered bandwidth.

The remedy: if the full-size images in galleries you build with thumbspage load too slowly, your recourses include moving to a faster hosting server, and downscaling the size or quality of very large images. Of these, downscaling images may be easiest, cheapest, and politest. The Pillow library, for instance, has tools that you can leverage in a Python script to reduce image filesize by scaling down image dimensions and quality. Better yet, get the new shrinkpix program for a precoded solution that uses Pillow this way to reduce the size of one or all image files in your website. However you opt to shrink, be sure to regenerate thumbspage galleries to reflect your newly shrunk images' information displayed in info popups.

A faster, and perhaps dedicated, server may help too, but not for users on metered connections or slow client networks; for such visitors, smaller images (e.g., < 500K) may be the only fix, and even then will solve speed issues only if network throttling isn't extreme. The website hosting thumbspage has resisted downscaling its images in the past for the sake of both image quality and usage demonstration, but at this writing is in the process of shrinking images globally. Downscaled or not, if images here are still slow for you, you can always view most of this site's thumbspage demos by downloading and unzipping to your machine and viewing locally. This includes thumbspage's own examples—fetch its full package for quick off-line image views.

In a better world, online images would by now be immune to the scourges of metered access and traffic bottlenecks. In the world in which we code, profit will probably always trump societal need, and the web's mass popularity will probably always best its technological progress.

Update: per testing so far, shrinking large images with the shrinkpix program mentioned above both removes observed slowdowns, and seems to yield faster views. The primary downsides are minor and rare reductions in full-size image quality (described in shrinkpix's caveats), and potentially degraded quality for thumbnails. thumbspage 1.7 solved the latter issue by converting some images to "RGBA" color mode temporarily when making their thumbnails; this produces results as good as for unshrunk originals, and has the added benefit of improving thumbnail quality for some unshrunk GIF images too. See the 1.7 update note and shrinkpix docs for more details.

Update: with the benefit of hindsight, most of the speed issues related to images at thumbspage's site stemmed from web-host speed, not image-file size. Speed issues were finally resolved in full in Spring 2020, by moving this site from its former GoDaddy host to an AWS Lightsail VPS server. The speed increase for thumbspage galleries was staggering, and far surpassed the gain from reduced image-file size (which was so overshadowed by host sloth, that it could not be reliably measured). Still, shrinking images was important for users on metered-bandwidth clients; images at this site are all now 500K or less (and average about half that size), and that's much less to ask of casual browsers than the former 6M bandwidth bombs.

Update: for completeness, it's worth noting that you can shrink a website's images dynamically with Apache's mod_pagespeed (a.k.a. PageSpeed) module. This ambitious module attempts to optimize size of fetched images by automatically resizing and caching for future requests. Unfortunately, you have little control over this process—or the quality of the images it produces. Worse, this module also mangles page code for transmission (a rude nonstarter for sites that double as page-coding resources), and abruptly crashed this site's Apache server when applied by default by a Bitnami install stack (despite the module's experimental "Incubating" status). Your mileage may vary, but static image-size reduction seems a more deterministic—and safer—approach.