2023-08-08 09:39:51 -05:00
< script lang = "ts" >
2024-02-14 06:38:57 -08:00
import { Colorspace , type SystemConfigDto } from '@immich/sdk';
2023-08-08 09:39:51 -05:00
import { isEqual } from 'lodash-es';
2024-01-12 18:44:11 +01:00
import { createEventDispatcher } from 'svelte';
2024-01-20 13:47:41 -05:00
import { fade } from 'svelte/transition';
2024-01-12 18:44:11 +01:00
import type { SettingsEventType } from '../admin-settings';
2024-02-22 15:36:14 +01:00
import SettingSelect from '$lib/components/shared-components/settings/setting-select.svelte';
import SettingSwitch from '$lib/components/shared-components/settings/setting-switch.svelte';
import SettingButtonsRow from '$lib/components/shared-components/settings/setting-buttons-row.svelte';
import SettingInputField, {
SettingInputFieldType,
} from '$lib/components/shared-components/settings/setting-input-field.svelte';
2023-08-08 09:39:51 -05:00
2024-01-12 18:44:11 +01:00
export let savedConfig: SystemConfigDto;
export let defaultConfig: SystemConfigDto;
export let config: SystemConfigDto; // this is the config that is being edited
2023-08-25 19:44:52 +02:00
export let disabled = false;
2023-08-08 09:39:51 -05:00
2024-01-12 18:44:11 +01:00
const dispatch = createEventDispatcher< SettingsEventType > ();
2023-08-08 09:39:51 -05:00
< / script >
< div >
2024-01-12 18:44:11 +01:00
< div in:fade = {{ duration : 500 }} >
< form autocomplete = "off" on:submit | preventDefault >
< div class = "ml-4 mt-4 flex flex-col gap-4" >
< SettingSelect
2024-04-02 00:56:56 -04:00
label="THUMBNAIL RESOLUTION"
2024-01-12 18:44:11 +01:00
desc="Used when viewing groups of photos (main timeline, album view, etc.). Higher resolutions can preserve more detail but take longer to encode, have larger file sizes, and can reduce app responsiveness."
number
2024-04-02 00:56:56 -04:00
bind:value={ config . image . thumbnailSize }
2024-01-12 18:44:11 +01:00
options={[
{ value : 1080 , text : '1080p' } ,
{ value : 720 , text : '720p' } ,
{ value : 480 , text : '480p' } ,
{ value : 250 , text : '250p' } ,
{ value : 200 , text : '200p' } ,
]}
name="resolution"
2024-04-02 00:56:56 -04:00
isEdited={ config . image . thumbnailSize !== savedConfig . image . thumbnailSize }
2024-01-12 18:44:11 +01:00
{ disabled }
/>
< SettingSelect
2024-04-02 00:56:56 -04:00
label="PREVIEW RESOLUTION"
2024-01-12 18:44:11 +01:00
desc="Used when viewing a single photo and for machine learning. Higher resolutions can preserve more detail but take longer to encode, have larger file sizes, and can reduce app responsiveness."
number
2024-04-02 00:56:56 -04:00
bind:value={ config . image . previewSize }
2024-01-12 18:44:11 +01:00
options={[
{ value : 2160 , text : '4K' } ,
{ value : 1440 , text : '1440p' } ,
{ value : 1080 , text : '1080p' } ,
{ value : 720 , text : '720p' } ,
]}
name="resolution"
2024-04-02 00:56:56 -04:00
isEdited={ config . image . previewSize !== savedConfig . image . previewSize }
2024-01-12 18:44:11 +01:00
{ disabled }
/>
< SettingInputField
inputType={ SettingInputFieldType . NUMBER }
label="QUALITY"
2024-04-02 00:56:56 -04:00
desc="Image quality from 1-100. Higher is better for quality but produces larger files."
bind:value={ config . image . quality }
isEdited={ config . image . quality !== savedConfig . image . quality }
2024-01-12 18:44:11 +01:00
/>
< SettingSwitch
title="PREFER WIDE GAMUT"
subtitle="Use Display P3 for thumbnails. This better preserves the vibrance of images with wide colorspaces, but images may appear differently on old devices with an old browser version. sRGB images are kept as sRGB to avoid color shifts."
2024-04-02 00:56:56 -04:00
checked={ config . image . colorspace === Colorspace . P3 }
on:toggle={( e ) => ( config . image . colorspace = e . detail ? Colorspace.P3 : Colorspace.Srgb )}
isEdited={ config . image . colorspace !== savedConfig . image . colorspace }
2024-01-12 18:44:11 +01:00
/>
< / div >
< div class = "ml-4" >
< SettingButtonsRow
2024-04-02 00:56:56 -04:00
on:reset={({ detail }) => dispatch ( 'reset' , { ... detail , configKeys : [ 'image' ] })}
on:save={() => dispatch ( 'save' , { image : config.image })}
2024-01-12 18:44:11 +01:00
showResetToDefault={ ! isEqual ( savedConfig , defaultConfig )}
{ disabled }
/>
< / div >
< / form >
< / div >
2023-08-08 09:39:51 -05:00
< / div >