App-sitelenmute

 view release on metacpan or  search on metacpan

script/sitelen-mute  view on Meta::CPAN

#!/usr/bin/env perl
# A modern, minimalist javascript photo gallery
# Copyright© 2016-2025  Alex Schroeder <alex@gnu.org>
# Copyright©      2018  Adrian Steinmann <ast@marabu.ch>
# Copyright© 2011-2016  wave++ "Yuri D'Elia" <wavexx@thregr.org>

=encoding utf8

=head1 NAME

Sitelen Mute - a static, minimalist photo gallery

=head1 SYNOPSIS

B<sitelen-mute> [B<OPTION> ...] I<SOURCE> I<DIRECTORY>

=head1 DESCRIPTION

B<Sitelen Mute> is a static photo gallery generator. It takes all the images it
can find in the source directory and writes a static gallery to the output
directory: scaled images, zipped originals, thumbnails, Javascript code for
navigation, and an HTML file. You can upload this to a simple web server.

B<-h>, B<--help> shows this help.

B<-v> increases the verbosity. Repeat for more detail.

B<-s> produces "slim" output: no original files or album to download. The
default is to create a zip file with all the originals in it. Creating a zip
files requires the C<zip> or C<7za> (7-Zip).

B<-i> include originals as individual files. The default is to create a just a
zip file with all the originals in it.

B<-d> skip creation of a full album zip file for download. Visitors can download
it by clicking the floppy icon with the downward arrow in the top left corner.

B<-c> I<METHODS> names the caption extraction methods, separated by commas.
Valid options are C<txt>, C<xmp>, C<exif>, C<cmt>, and C<none>. When multiple
methods are provided, the first available caption source is used. By default,
the method list is C<txt,xmp,exif>. You can disable caption extraction entirely
by using C<none>.

C<txt> reads the caption from a text file that has the same name as the image,
but with C<txt> extension (for example F<IMG1234.jpg> reads from
F<IMG1234.txt>). The first line of the file (which can be empty) constitutes the
title, with any following line becoming the description. These files can either
be written manually, or can be edited more conveniently using C<fcaption>. It
accepts a list of filenames or directories on the command line, and provides a
simple visual interface to quickly edit image captions in this format.

C<xmp> reads the caption from XMP sidecar metadata and C<exif> reads the caption
from EXIF metadata. Tools such as I<Darktable> or I<Geeqie> can write such
files. Use C<Ctrl+K> to bring up the metadata editor.

C<cmt> reads the caption from JPEG or PNG's built-in comment data. Both JPEG and
PNG have a built-in comment field, but it's not read by default as it's often
abused by editing software to put attribution or copyright information.

Captions can be controlled by the user using the speech bubble icon or by
pressing the C<c> keyboard shortcut, which cycles between normal, always hidden
and always shown visualisation modes.

B<-k> prevents the modification of the image files. The default is to
auto-orient images and to optimise JPEG and PNG files. Optimisation requires
C<jpegoptim> or C<pngcrush>.

B<-o> prevents auto-orientation of images. Lossless auto-orientation requires
one of C<exiftran> or C<exifautotran>.

B<-t> prevents sorting by time. Sorting by time is important if mixing the
pictures of multiple cameras.

B<-t> reverses the album order.

B<-p> prevents the inclusion of full-sized panoramas.

B<-n> I<NAME> sets the album name, i.e. the title in the browser window.

B<--index> I<URL> is the location for the index/back button.

The following three options add meta tags for previews on social media. They
must all three be specified, if at all.

B<--url> I<URL> is the eventual URL of the gallery. That is, you need to know
where you're uploading the gallery to.

B<--title> I<TITLE> is the title for previews on social media.

B<--description> I<DESCRIPTION> is the (longer) description to use for the
preview on social media.

B<-f> improves thumbnails by using face detection. This requires C<facedet>.

B<--noblur> skips the generation of blurry backdrops and simply uses dark noise
instead.

B<--max-full> I<WxH> specifies the maximum full image size (the default is
1600×1200).

B<--max-thumb> I<WxH> specifies the maximum thumbnail size (the default is
267×200).

B<--min-thumb> I<WxH> specifies the minimum thumbnail size (the default is
150×112).

B<--no-sRGB> prevents the remapping of previews and thumbnail colour profiles to
sRGB. The remapping requires C<tificc>.

B<--quality> I<Q> specifies the preview image quality (0-100, currently: 90).

B<--link-orig> I<method> specifies the copy method to use: one of C<copy>,
C<hard>, C<sym>, or C<ref>); the default is C<copy>. C<copy> uses regular C<cp>;
C<hard> uses hard links: C<cp --link>, or C<ln> on BSD; C<sym> uses symbolic
links: C<cp --symbolic-link>, or C<ln -s> on BSD; C<ref> uses lightweight copy,
where the data blocks are copied only when modified: C<cp --reflink>, and it is
not supported on BSD.

B<--viewdir> specifies the directory containing CSS/JavaScript that is copied
into the target directory.

B<--version> prints the version.

=head1 EXAMPLES

Generate a simple gallery:

    sitelen-mute photo-dir my-gallery

To favour photos shot in portrait format, invert the
width/height of the thumbnail sizes:

  sitelen-mute --min-thumb 112x150 --max-thumb 200x267 \
     photo-dir my-gallery

This forces the thumbnails to always fit vertically, at the expense of a higher
horizontal thumbnail strip.

For a real world example including face detection and meta data for social
media, with the images stored in the F<Quito> directory and the gallery ending
up in F<2020-quito>:

    sitelen-mute -f --title "Quito 2020" \
      --description "On our way to the Galápagos we stopped for a few days in Quito, Ecuador." \
      --url https://alexschroeder.ch/gallery/2020-quito/ \
      Quito \
      2020-quito

=head1 TROUBLESHOOTING

This section talks about strange and weird problems and how to work around them.

=head2 cannot load gallery data

To test or preview the gallery locally, you might think that you can just open
the F<index.html> file of the gallery. Sadly, this is no longer the case for
security reasons (the "same-origin policy"; learn more about it on Wikipedia).

If you have Python installed, a quick way to test the gallery locally is to run
the following inside the gallery:

    python -m SimpleHTTPServer 8000

This serves all the files from C<http://localhost:8000>.

=head2 convert: width or height exceeds limit

An error message containing "convert-im6.q16: width or height exceeds limit" is
a sign that your ImageMagick installation has a security policy that prevents
"image bombs" – images that are so large that they could bomb your server if you
is using ImageMagick to process images uploaded from the Internet. If you a
I<sure> that you are not using ImageMagick in this way, here's a way to disable
this security policy.

You can show the limits using C<identify -list resource>:

    Resource limits:
      Width: 16KP
      Height: 16KP
      List length: 18.446744EP
      Area: 128MP
      Memory: 256MiB
      Map: 512MiB
      Disk: 1GiB
      File: 768
      Thread: 4
      Throttle: 0
      Time: unlimited

Compare this to the image using C<identify IMG_1234.JPG>. Clearly, this panorama
image is too big.

    IMG_1234.JPG JPEG 16382x3628 16382x3628+0+0 8-bit sRGB 25.6993MiB 0.000u 0:00.000

As root, you need to change the security policy of your installation
if you want to process such large panorama shots. Edit
F</etc/ImageMagick-6/policy.xml> and make the following change:

    62c62
    <   <policy domain="resource" name="width" value="16KP"/>
    ---
    >   <policy domain="resource" name="width" value="32KP"/>

=head1 FEATURES

There is no server-side processing, only static generation. The resulting
gallery can be uploaded anywhere without additional requirements and works with
any modern browser.

=over

=item Automatically orients pictures without quality loss.

=item Multi-camera friendly: automatically sorts pictures by time: just throw
  your (and your friends) photos and movies in a directory. The resulting
  gallery shows the pictures in seamless shooting order.

=item Adapts to the current screen size and proportions, switching from
  horizontal/vertical layout and scaling thumbnails automatically.

=item Supports face detection for improved thumbnail centring.

=item Loads fast! Especially over slow connections.

=item Images shown by the viewer are scaled, compressed, and stripped of EXIF
  tags for size

=item Includes original (raw) pictures in a zip file for downloading.

=item Panoramas can be seen full-size by default.

=back

=head1 COLOUR MANAGEMENT

Since every camera is different, and every monitor is different, some colour
transformation is necessary to reproduce the colours on your monitor as
*originally* captured by the camera. Colour management is an umbrella term for
all the techniques required to perform this task.

Most image-viewing software support colour management to some degree, but it's
rarely configured properly on most systems except for Safari on macOS. No other
browser, unfortunately, supports decent colour management.

This causes the familiar effect of looking at the same picture from your laptop
and your tablet, and noticing that the blue of the sky is just slightly off, or
that the contrast seems to be much higher on one screen as opposed to the other.
Often the image has the information required for a more balanced colour
reproduction, but the browser is just ignoring it.

Colour management has a considerable impact on image rendering performance, but
strictly speaking colour management doesn't need to be enabled on all images by
default. It would be perfectly fine to have an additional attribute on the image
tag to request colour management. The current method of enabling colour
management only on images with an ICC profile is clearly not adequate, since
images without a profile should be assumed to be in sRGB colour-space already.

Because of the general lack of colour management, *Sitelen Mute* transforms the
preview and thumbnail images from the built-in colour profile to the sRGB
colour-space by default. On most devices this will result in images appearing to
be *closer* to true colours with only minimal lack of absolute colour depth. As
usual, no transformation is done on the original downloadable files.

=head1 DEPENDENCIES

The viewer has no external dependencies. It's static HTML/CSS, and Javascript.



( run in 1.376 second using v1.01-cache-2.11-cpan-b16cb0d3907 )