Thumbnails: Difference between revisions

Crazivik (talk | contribs)
Reorganised Headings and Subheadings, improved Video subsection, added Image subsection
Crazivik (talk | contribs)
Added subsection for 'raw' / camera image format thumbnails
Line 10: Line 10:
To enable thumbnails for video files use <code>ffmpeg-headless</code> to decode videos and <code>fmpegthumbnailer</code> to generate thumbnails.
To enable thumbnails for video files use <code>ffmpeg-headless</code> to decode videos and <code>fmpegthumbnailer</code> to generate thumbnails.


Thumbnails for the following MimeTypes will be enabled: ''video/jpeg; video/mp4; video/mpeg; video/quicktime; video/x-ms-asf; video/x-ms-wm; video/x-ms-wmv; video/x-ms-asx; video/x-ms-wmx; video/x-ms-wvx; video/x-msvideo; video/x-flv; video/x-matroska; application/x-matroska; application/mxf; video/3gp; video/3gpp; video/dv; video/divx; video/fli; video/flv; video/mp2t; video/mp4v-es; video/msvideo; video/ogg; video/vivo; video/vnd.avi; video/vnd.divx; video/vnd.mpegurl; video/vnd.rn-realvideo; application/vnd.rn-realmedia; video/vnd.vivo; video/webm; video/x-anim; video/x-avi; video/x-flc; video/x-fli; video/x-flic; video/x-m4v; video/x-mpeg; video/x-mpeg2; video/x-nsv; video/x-ogm+ogg; video/x-theora+ogg.''
Thumbnails for the following MimeTypes are enabled: ''video/jpeg; video/mp4; video/mpeg; video/quicktime; video/x-ms-asf; video/x-ms-wm; video/x-ms-wmv; video/x-ms-asx; video/x-ms-wmx; video/x-ms-wvx; video/x-msvideo; video/x-flv; video/x-matroska; application/x-matroska; application/mxf; video/3gp; video/3gpp; video/dv; video/divx; video/fli; video/flv; video/mp2t; video/mp4v-es; video/msvideo; video/ogg; video/vivo; video/vnd.avi; video/vnd.divx; video/vnd.mpegurl; video/vnd.rn-realvideo; application/vnd.rn-realmedia; video/vnd.vivo; video/webm; video/x-anim; video/x-avi; video/x-flc; video/x-fli; video/x-flic; video/x-m4v; video/x-mpeg; video/x-mpeg2; video/x-nsv; video/x-ogm+ogg; video/x-theora+ogg.''


<syntaxhighlight lang="nix"># configuration.nix
<syntaxhighlight lang="nix"># configuration.nix
Line 29: Line 29:
   ];
   ];


}</syntaxhighlight>
}
</syntaxhighlight>


=== Enable Image Thumbnails ===
=== Enable Image Thumbnails ===
To enable thumbnails for image files use <code>gdk-pixbuf</code> to decode images and generate thumbnails.
To enable thumbnails for image files use <code>gdk-pixbuf</code> to decode images and generate thumbnails.


Thumbnails for the following MimeTypes will be enabled: ''image/png; image/jpeg; image/bmp; image/x-bmp; image/x-MS-bmp; image/gif; image/x-icon; image/x-ico; image/x-win-bitmap; image/vnd.microsoft.icon; application/ico; image/ico; image/icon; text/ico; image/x-portable-anymap; image/x-portable-bitmap; image/x-portable-graymap; image/x-portable-pixmap; image/tiff; image/x-xpixmap; image/x-xbitmap; image/x-tga; image/x-icns; image/x-quicktime; image/qtif.''
Thumbnails for the following MimeTypes are enabled: ''image/png; image/jpeg; image/bmp; image/x-bmp; image/x-MS-bmp; image/gif; image/x-icon; image/x-ico; image/x-win-bitmap; image/vnd.microsoft.icon; application/ico; image/ico; image/icon; text/ico; image/x-portable-anymap; image/x-portable-bitmap; image/x-portable-graymap; image/x-portable-pixmap; image/tiff; image/x-xpixmap; image/x-xbitmap; image/x-tga; image/x-icns; image/x-quicktime; image/qtif.''


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix"># configuration.nix
# configuration.nix
{ pkgs, ... }:  
{ pkgs, ... }:  
{
{
Line 53: Line 53:
   ];
   ];


}
}</syntaxhighlight>
</syntaxhighlight>


=== Enable HEIF Image Thumbnails ===
=== Enable HEIF Image Thumbnails ===
To enable thumbnails for HEIF image format use <code>libheif</code> to decode HEIF images and <code>libheif.out</code> to generate thumbnails.
To enable thumbnails for HEIF image format use <code>libheif</code> to decode HEIF images and <code>libheif.out</code> to generate thumbnails.


Thumbnails for the following MimeTypes will be enabled: ''image/heif; image/avif.''
Thumbnails for the following MimeTypes are enabled: ''image/heif; image/avif.''


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
Line 73: Line 72:
   # 'heif.thumbnailer' is created in '/run/current-system/sw/share/thumbnailers'  
   # 'heif.thumbnailer' is created in '/run/current-system/sw/share/thumbnailers'  
     # but thumbnails are not displayed unless symlinks to 'share/thumbnailers' are also defined
     # but thumbnails are not displayed unless symlinks to 'share/thumbnailers' are also defined
  # uncomment if this has already been defined in your configuration.nix
  environment.pathsToLink = [
  "share/thumbnailers"
  ];
}
</syntaxhighlight>
=== Enable RAW (Camera) Image Thumbnails ===
==== nufraw-thumbnailer ====
To enable thumbnails for camera RAW format use <code>nufraw</code> to decode RAW images and <code>nufraw-thumbnailer</code> to generate thumbnails.
Thumbnails for the following MimeTypes are enabled: ''image/x-canon-cr2;image/x-canon-crw;image/x-minolta-mrw;image/x-nikon-nef;image/x-pentax-pef;image/x-panasonic-rw2;image/x-panasonic-raw2;image/x-samsung-srw;image/x-olympus-orf;image/x-sony-arw.''
<syntaxhighlight lang="nix"># configuration.nix
{ pkgs, ... }:
{
  environment.systemPackages = with pkgs; [
    nufraw
    nufraw-thumbnailer
  ];
  # 'nufraw.thumbnailer' is created in '/run/current-system/sw/share/thumbnailers'
    # but thumbnails are not displayed unless symlinks to 'share/thumbnailers' are also defined
  # uncomment if this has already been defined in your configuration.nix
  environment.pathsToLink = [
  "share/thumbnailers"
  ];
}</syntaxhighlight>
By default nufraw-thumbnailer 
* creates thumbnails using the embedded 'jpeg' in the camera raw files. ( <code>--noexif</code> )
* does not respect the EXIF metadata. ( <code>--embedded-image</code> )
Output of <code>cat /run/current-system/sw/share/thumbnailers/nufraw.thumbnailer</code>:
<syntaxhighlight lang="nix">
[Thumbnailer Entry]
TryExec=/nix/store/piss9dl8i5xnfm5yagdffgxycm8lsqpl-nufraw-0.43-3/bin/nufraw-batch
Exec=/nix/store/piss9dl8i5xnfm5yagdffgxycm8lsqpl-nufraw-0.43-3/bin/nufraw-batch --silent --size %s --out-type=png --noexif --output=%o --embedded-image %i
MimeType=image/x-canon-cr2;image/x-canon-crw;image/x-minolta-mrw;image/x-nikon-nef;image/x-pentax-pef;image/x-panasonic-rw2;image/x-panasonic-raw2;image/x-samsung-srw;image/x-olympus-orf;image/x-sony-arw
</syntaxhighlight>
Additional cameras<ref>https://github.com/killhellokitty/nufraw-thumbnailer</ref> beyond those listed in the stock <code>nufraw.thumbnailer</code> file are also supported. The following additional MimeTypes are supported: ''image/x-adobe-dng; image/x-dcraw; image/x-fuji-raf; image/x-kodak-dcr; image/x-kodak-k25; image/x-kodak-kdc; image/x-nikon-nrw; image/x-panasonic-raw; image/x-sigma-x3f; image/x-sony-srf; image/x-sony-sr2''
Eg: Generate thumbnails from 'raw' data (not 'embedded jpeg') + respect EXIF (eg: rotation) metadata + add support for additional camera formats
<syntaxhighlight lang="nix">
# configuration.nix
{ pkgs, ... }:
{
  environment.systemPackages = [
    nufraw
    nufraw-thumbnailer
    # Thumbnails form 'raw' data and include EXIF tags for Adobe-DNG images
    (writeTextDir "share/thumbnailers/my-custom-nufraw.thumbnailer" ''
      [Thumbnailer Entry]
      TryExec=nufraw-batch
      Exec=nufraw-batch --silent --size %s --out-type=png --output=%o %i
      MimeType=image/x-adobe-dng;image/x-dng;
    '';)
    # MimeTypes not listed here but listed in the default nufraw.thumbnailer will continue displaying
      # thumbnails generated form the 'embedded jpeg' without the EXIF metadata
  ];
  # uncomment if this has already been defined in your configuration.nix
  environment.pathsToLink = [
  "share/thumbnailers"
  ];
}
</syntaxhighlight>
==== gdk-pixbuf thumbnailer ====
The gdk-pixbuf thumbnailer can also generate thumbnails (from the 'embedded jpeg') for RAW camera image formats. It cannot decode the 'raw' image data but can read the 'embedded jpeg'.
<syntaxhighlight lang="nix">
# configuration.nix
{ pkgs, ... }:
{
  environment.systemPackages = [
    gdk-pixbuf
    (writeTextDir "share/thumbnailers/my-custom-nufraw.thumbnailer" ''
      [Thumbnailer Entry]
      TryExec=gdk-pixbuf-thumbnailer
      Exec=gdk-pixbuf-thumbnailer -s %s %u %o
      MimeType=image/x-adobe-dng;image/x-dng;image/x-canon-cr2;image/x-canon-crw;image/x-cr2;image/x-crw;
    '';)
  ];


   # uncomment if this has already been defined in your configuration.nix
   # uncomment if this has already been defined in your configuration.nix
Line 109: Line 206:
After you have a working definition, you can make it reproducible like so:
After you have a working definition, you can make it reproducible like so:


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix"># configuration.nix
# configuration.nix
{ pkgs, ... }: {
{ pkgs, ... }: {
   environment.systemPackages = [
   environment.systemPackages = [
Line 128: Line 224:
     )
     )
   ];
   ];
}
}</syntaxhighlight>
</syntaxhighlight>