2020-08-12 13:16:25 +02:00
|
|
|
package config
|
|
|
|
|
2022-03-02 12:20:02 +01:00
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
|
|
|
|
"github.com/photoprism/photoprism/pkg/sanitize"
|
|
|
|
)
|
|
|
|
|
2021-05-01 10:25:34 +02:00
|
|
|
// RawPresets tests if RAW converter presents should be used (may reduce performance).
|
|
|
|
func (c *Config) RawPresets() bool {
|
|
|
|
return c.options.RawPresets
|
2021-04-30 14:24:01 +02:00
|
|
|
}
|
|
|
|
|
2020-08-12 13:16:25 +02:00
|
|
|
// DarktableBin returns the darktable-cli executable file name.
|
|
|
|
func (c *Config) DarktableBin() string {
|
2020-12-18 20:42:12 +01:00
|
|
|
return findExecutable(c.options.DarktableBin, "darktable-cli")
|
2020-08-12 13:16:25 +02:00
|
|
|
}
|
|
|
|
|
2021-09-21 15:33:46 +02:00
|
|
|
// DarktableBlacklist returns the darktable file extension blacklist.
|
|
|
|
func (c *Config) DarktableBlacklist() string {
|
|
|
|
return c.options.DarktableBlacklist
|
|
|
|
}
|
|
|
|
|
2022-03-02 12:20:02 +01:00
|
|
|
// DarktableConfigPath returns the darktable config directory.
|
|
|
|
func (c *Config) DarktableConfigPath() string {
|
|
|
|
dir := filepath.Join(c.ConfigPath(), "darktable")
|
|
|
|
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
|
|
|
|
log.Errorf("darktable: cannot create config directory %s, check permissions", sanitize.Log(dir))
|
|
|
|
return c.ConfigPath()
|
|
|
|
}
|
|
|
|
return dir
|
|
|
|
}
|
|
|
|
|
|
|
|
// DarktableCachePath returns the darktable cache directory.
|
|
|
|
func (c *Config) DarktableCachePath() string {
|
|
|
|
dir := filepath.Join(c.CachePath(), "darktable")
|
|
|
|
|
|
|
|
if err := os.MkdirAll(dir, os.ModePerm); err != nil {
|
|
|
|
log.Errorf("darktable: cannot create cache directory %s, check permissions", sanitize.Log(dir))
|
|
|
|
return c.ConfigPath()
|
|
|
|
}
|
|
|
|
|
|
|
|
return dir
|
|
|
|
}
|
|
|
|
|
2021-04-30 14:24:01 +02:00
|
|
|
// DarktableEnabled tests if Darktable is enabled for RAW conversion.
|
|
|
|
func (c *Config) DarktableEnabled() bool {
|
|
|
|
return !c.DisableDarktable()
|
|
|
|
}
|
|
|
|
|
2021-05-01 10:25:34 +02:00
|
|
|
// RawtherapeeBin returns the rawtherapee-cli executable file name.
|
|
|
|
func (c *Config) RawtherapeeBin() string {
|
|
|
|
return findExecutable(c.options.RawtherapeeBin, "rawtherapee-cli")
|
|
|
|
}
|
|
|
|
|
2021-09-21 15:33:46 +02:00
|
|
|
// RawtherapeeBlacklist returns the RawTherapee file extension blacklist.
|
|
|
|
func (c *Config) RawtherapeeBlacklist() string {
|
|
|
|
return c.options.RawtherapeeBlacklist
|
|
|
|
}
|
|
|
|
|
2021-05-01 10:25:34 +02:00
|
|
|
// RawtherapeeEnabled tests if Rawtherapee is enabled for RAW conversion.
|
|
|
|
func (c *Config) RawtherapeeEnabled() bool {
|
|
|
|
return !c.DisableRawtherapee()
|
2020-08-12 13:16:25 +02:00
|
|
|
}
|
|
|
|
|
2021-04-30 14:24:01 +02:00
|
|
|
// SipsEnabled tests if SIPS is enabled for RAW conversion.
|
|
|
|
func (c *Config) SipsEnabled() bool {
|
|
|
|
return !c.DisableSips()
|
|
|
|
}
|
|
|
|
|
|
|
|
// SipsBin returns the SIPS executable file name.
|
2020-08-12 13:16:25 +02:00
|
|
|
func (c *Config) SipsBin() string {
|
2020-12-18 20:42:12 +01:00
|
|
|
return findExecutable(c.options.SipsBin, "sips")
|
2020-08-12 13:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// HeifConvertBin returns the heif-convert executable file name.
|
|
|
|
func (c *Config) HeifConvertBin() string {
|
2020-12-18 20:42:12 +01:00
|
|
|
return findExecutable(c.options.HeifConvertBin, "heif-convert")
|
2020-08-12 13:16:25 +02:00
|
|
|
}
|
2021-04-30 14:24:01 +02:00
|
|
|
|
|
|
|
// HeifConvertEnabled tests if heif-convert is enabled for HEIF conversion.
|
|
|
|
func (c *Config) HeifConvertEnabled() bool {
|
|
|
|
return !c.DisableHeifConvert()
|
|
|
|
}
|