Thumbnails: Difference between revisions

Added a header so the newer image format section is more visible
Add exiv2-thumbnailer
Line 117: Line 117:
     # Other MimeTypes that include embedded jpeg may work as well (e.g. Nikon .nef, Sony .arf, etc)
     # Other MimeTypes that include embedded jpeg may work as well (e.g. Nikon .nef, Sony .arf, etc)
     # Test other formats by adding them above
     # Test other formats by adding them above
  ];
}</syntaxhighlight>
'''exiv2-thumbnailer'''
exiv2 can as well generate thumbnails for RAW camera formats by extracting their embedded JPEG or TIFF previews, making thumbnail creation fast without full RAW decoding. It may also support a wider range of RAW formats than gdk‑pixbuf, since it works directly with metadata rather than relying on codec‑level image loaders.<syntaxhighlight lang="nix">
# configuration.nix
{ pkgs, ... }:
{
  environment.systemPackages = [
    # exiv2-based RAW thumbnailer (extracts embedded JPEG/TIFF)
    (pkgs.writeShellApplication {
      name = "exiv2-thumbnailer";
      runtimeInputs = [ pkgs.exiv2 pkgs.imagemagick ];
      text = ''
        #!${pkgs.bash}/bin/bash
        set -euo pipefail
        tmpdir="$(mktemp -d)"
        trap 'rm -rf "$tmpdir"' EXIT
        exiv2 -l "$tmpdir" --extract p1 "$1"
        base="$(basename "$1")"
        preview="$tmpdir/${base%.*}-preview1.jpg"
        [ ! -f "$preview" ] && preview="${preview%.*}.tif"
        magick "$preview" -thumbnail "${3}x${3}>" -strip "png:$2"
      '';
    })
    (pkgs.writeTextFile {
      name = "exiv2-thumbnailer.thumbnailer";
      destination = "/share/thumbnailers/exiv2-thumbnailer.thumbnailer";
      text = ''
        [Thumbnailer Entry]
        TryExec=exiv2-thumbnailer
        Exec=exiv2-thumbnailer %i %o
        MimeType=image/x-adobe-dng;image/x-sony-arw;image/x-nikon-nef;
      '';
    })
   ];
   ];
}
}
</syntaxhighlight>
 
</syntaxhighlight>For a more complete solution, see the NixOS port of [https://github.com/stackcoder/nixos-nautilus-raw-thumbnails nautilus‑raw‑thumbnails].


==== nufraw-thumbnailer ====
==== nufraw-thumbnailer ====