Configuration

HomeGallery has serveral modules/parts which can be configured through the gallery.config.yml file. It is loaded on the start of the CLI and is created if not found. It comes with a well selected preset of settings.

In a bare minimum configuration you need to define your media directories:

1sources:
2  - ~/Pictures

By default the configuration files are stored to ~/.config/home-gallery and the previews are stored in ~/.cache/home-gallery/storage.

It is advisable to initialize the configuration through the run init command:

gallery run init --source ~/Pictures /mnt/media

Full configuration

The full configuration contains valuable details to some settings

  1#
  2# HomeGallery configuration file
  3#
  4#
  5# Default configuration file is gallery.config.yml. JSON format is
  6# also supported (gallery.config.json)
  7#
  8# This is a comment, starting with hash tag and space ('# ')
  9# A default value starting with hash tag and variable ('#baseDir...')
 10#
 11# Directory value examples:
 12# - /absolute/directory
 13# - relative/directory/to/current/working/dir
 14# - ~/directory/in/your/home
 15# - ./relative/directory/to/configuration/file
 16#
 17# Variable replacements
 18#   baseDir: '~'
 19#   configDir: '{baseDir}/.config/home-gallery'
 20# configDir is replaced to '~/.config/home-gallery' and than to '$HOME/.config/home-gallery'
 21#
 22# Variables are overwritten by environment variables
 23#
 24# Variables are baseDir, configDir, configPrefix, cacheDir and dir in sources
 25# or environment variables GALLERY_BASE_DIR, GALLERY_CONFIG_DIR, GALLERY_CONFIG_PREFIX, GALLERY_CACHE_DIR
 26
 27#
 28# General
 29#
 30#baseDir: '~'
 31#configDir: '{baseDir}/.config/home-gallery'
 32# file prefix for index, database and events
 33#configPrefix: ''
 34#cacheDir: '{baseDir}/.cache/home-gallery'
 35
 36#
 37# Sources
 38#
 39# List of media source directories. These can be read only.
 40#
 41# All sources are used to build the gallery database. If you need
 42# different databases or gallery instances use different gallery
 43# configurations
 44sources:
 45  - dir: '{baseDir}/Pictures'
 46    #index: '{configDir}/{configPrefix}{basename(dir)}.idx'
 47    # excludes are using gitignore patterns
 48    #excludes:
 49      #- .DS_Store
 50      #- ._*
 51      #- '*.tmp'
 52      #- '*cache*'
 53    #excludeIfPresent: .galleryignore
 54    # excludeFromFile: '{configDir}/excludes'
 55    # Use maxFilesize to exclude big files such as videos to speedup initial setup
 56    # maxFilesize: 20M
 57    # If source directory/disk is offline/unmounted set it to true.
 58    # Offline sources require an index file. Previews and meta data
 59    # should be extracted first before marking a source offline
 60    #offline: false
 61    # Filename matcher for checksum recalculation
 62    # size-ctime-inode: this matcher should be used if possible, might
 63    #                   not work on windows
 64    # size-ctime: this matcher should be used if stable fs inodes are
 65    #             not available and might not work for fuse shares
 66    # size: this matcher should be used if you know what you are doing
 67    #matcher: size-ctime-inode
 68
 69#
 70# Extractor settings
 71#
 72#extractor:
 73  # excludes:
 74  #   - *.xmp
 75  #   - *.svg
 76  # excludeFromFile: '{configDir}/excludes'
 77  # Preview image settings
 78  #image:
 79  #  previewSizes: [1920, 1280, 800, 320, 128]
 80  #  previewQuality: 80
 81  #video:
 82  #  previewSize: 720 # used as preview size and preview filename
 83  #  ext: mp4 # used as target video container and preview filename
 84  #  scale: -2:'min(720,ih)' # overwrites previewSize. E.g. -2:'min(ih,max(720,min(1080,ih*.5)))' for 720p <= height*0.5 <= 1080p or height, if height < 720
 85  #  frameRate: 30
 86  #  maxVideoBitRate: 4000 # in KB
 87  #  videoEncoder: libx264
 88  #  preset: slow
 89  #  profile: baseline
 90  #  level: '3.0'
 91  #  addFfmpegArgs: [...] # Additional ffmpeg args
 92  #  customFfmpegArgs: [...] # custom ffmpeg args for video conversion, replaces all other settings such previewSize, videoEncoder, addFfmpegArgs, ...
 93  # Api Server is used for image similarity, object and face detection
 94  #apiServer:
 95  #  url: https://api.home-gallery.org
 96  #  timeout: 30
 97  #  concurrent: 5
 98  #  disable:
 99  #    - similarDetection
100  #    - objectDetection
101  #    - faceDetection
102  #geoReverse:
103  #  url: https://nominatim.openstreetmap.org
104  #   Preffered address language of geo code reverse lookups
105  #   addressLanguage: [de, en-US] # for multiple languages
106  #  addressLanguage: [en, de]
107  # excludes are using gitignore patterns
108  #excludes: []
109  # Use native system commands. It is recoomended on armv6 and arm7 platform
110  # since the npm packages do not provide binaries for these platforms
111  #useNative:
112  #  - vipsthumbnail # use libvips to resize images
113  #  - convert # use ImageMagick to resize images
114  #  - ffprobe
115  #  - ffmpeg
116
117#
118# Storage and files configuration
119#
120#storage:
121  #dir: '{cacheDir}/storage'
122#database:
123  #file: '{configDir}/{configPrefix}database.db'
124  # The full database creation is memory consuming. The default value is 2048 MB.
125  # On memory errors or for larger photo collections (>50000 images) 4096 MB is recommended
126  # Use less memory for smaller devices (e.g. Raspberry Pi Zero), e.g. 512 MB.
127  # Node's default memory limit is 512 MB (changeable via --max-old-space-size node arg)
128  #maxMemory: 2048
129  # excludes:
130  #   - *.xmp
131  #   - *.svg
132  # excludeFromFile: '{configDir}/excludes'
133  # supportedTypes
134  #   - image
135  #   - rawImage
136  #   - video
137#events:
138  #file: '{configDir}/{configPrefix}events.db'
139
140#
141# Server configuration
142#
143#server:
144  #port: 3000
145  #host: '0.0.0.0'
146  # security configuration for https
147  # key: '{configDir}/server.key'
148  # cert: '{configDir}/server.crt'
149  # Open browser when server starts
150  #openBrowser: true
151  # Enable basic authentication users and ip whitelist rules which require no authentication
152  # First matching rule wins. Default rules are: allow: localhost and deny: all.
153  # Hashed password can be generated via
154  #   node -e "pw=process.argv[1];const {createHash,randomBytes}=require('crypto');salt=randomBytes(12);hash=createHash('sha256').update(salt.toString()+pw).digest('base64');console.log('{SHA256-salted}'+salt.toString('base64')+'.'+hash)" 'password'
155  #   {SHA256-salted}FkcbhhcHYW0DdE9u.P9Ik9MG8ldtO0fzGB+RV186vi8PZMomsya5OWC0AEiA=
156  #   node -e "pw=process.argv[1]||'';sha1=require('crypto').createHash('sha1').update(pw).digest('base64');console.log('{SHA}'+sha1)" password
157  #   {SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g=
158  # auth:
159  #  public:
160  #    filter: 'year >= 2024 tag:public' # Database filter for non authenticated users and non whitelisted IPs
161  #  users:
162  #    - username: password
163  #    - username: '{SHA}W6ph5Mm5Pz8GgiULbPgzG37mj9g='
164  #    - username: admin
165  #      password: '{SHA256-salted}FkcbhhcHYW0DdE9u.P9Ik9MG8ldtO0fzGB+RV186vi8PZMomsya5OWC0AEiA=' # passsword
166  #      filter: '' # no database filter for admin user
167  #    - username: guest
168  #      password: '{SHA256-salted}W1jrZgK81z06YLhA.qTSmeyYtPP19ZEpGiiAyVn61nly4jqbuuGoSefzLm98=' # guest
169  #      filter: 'year >= 2019 not tag:private'
170  #  rules:
171  #    - allow: localhost
172  #    - allow: '192.168/16'
173  #    - deny: all
174  # Prefix of application. E.g. /gallery
175  #prefix: /
176  # Prefix path for browser only. basePath is Overwritten by prefix
177  #basePath: /
178  #watchSources: true
179
180#
181# Webapp configuration
182#
183#webapp:
184  # Disabled webapp features
185  #disabled:
186    #- edit
187    #- serverEvents
188    #- pwa
189    #- offlineDatabase
190
191#
192# Plugin settings
193#
194#pluginManager:
195  # Directories to load. Each folder entry for or dir is handled as plugin
196  #dirs:
197    # First directory is default directory for plugin creation
198    #- plugins
199  # List of dedicated plugin files
200  #plugins:
201    #- pluginFile
202  #disabled:
203    #- acmePlugin
204    #- acmePlugin.extensionName
205
206# Plugin settings
207#plugin:
208  # Plugin name
209  #acme:
210    # Plugin setting
211    #prop: value
212
213logger:
214  # Currently console and file loggers are available
215  - type: console
216    # Log level could be one of trace, debug, info, warn, error, fatal, silent
217    level: info
218    # format: json
219  # File logger format is in newline delimited JSON. See http://ndjson.org
220  - type: file
221    # Log level could be one of trace, debug, info, warn, error, fatal, silent
222    level: debug
223    file: '{configDir}/{configPrefix}gallery.log'