Compare commits
5
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b8cf24974 | ||
|
|
1c12ead5a1 | ||
|
|
9999aba5e6 | ||
|
|
c092ab5f83 | ||
|
|
9299b68680 |
No files matched your search
Generated
+572
-21
@@ -8,6 +8,24 @@ version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||
|
||||
[[package]]
|
||||
name = "aligned"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee4508988c62edf04abd8d92897fca0c2995d907ce1dfeaf369dac3716a40685"
|
||||
dependencies = [
|
||||
"as-slice",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aligned-vec"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b"
|
||||
dependencies = [
|
||||
"equator",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "alloc-no-stdlib"
|
||||
version = "2.0.4"
|
||||
@@ -23,18 +41,108 @@ dependencies = [
|
||||
"alloc-no-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "anyhow"
|
||||
version = "1.0.104"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
|
||||
|
||||
[[package]]
|
||||
name = "arbitrary"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3bc62ac97cc33321f50863d514c3bc38a453947a8f9e781137e47c7401020aed"
|
||||
|
||||
[[package]]
|
||||
name = "arg_enum_proc_macro"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0ae92a5119aa49cdbcf6b9f893fe4e1d98b04ccbf82ee0584ad948a44a734dea"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "arrayvec"
|
||||
version = "0.7.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3fb67a6e08acf24fdeccbac2cb6ac4305825bd1f117462e0e6f2f193345ad56"
|
||||
|
||||
[[package]]
|
||||
name = "as-slice"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516"
|
||||
dependencies = [
|
||||
"stable_deref_trait",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "av-scenechange"
|
||||
version = "0.14.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f321d77c20e19b92c39e7471cf986812cbb46659d2af674adc4331ef3f18394"
|
||||
dependencies = [
|
||||
"aligned",
|
||||
"anyhow",
|
||||
"arg_enum_proc_macro",
|
||||
"arrayvec",
|
||||
"log",
|
||||
"num-rational",
|
||||
"num-traits",
|
||||
"pastey",
|
||||
"rayon",
|
||||
"thiserror",
|
||||
"v_frame",
|
||||
"y4m",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "av1-grain"
|
||||
version = "0.2.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8cfddb07216410377231960af4fcab838eaa12e013417781b78bd95ee22077f8"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"arrayvec",
|
||||
"log",
|
||||
"nom",
|
||||
"num-rational",
|
||||
"v_frame",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "avif-serialize"
|
||||
version = "0.8.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7178fe5f7d460b13895ebb9dcb28a3a6216d2df2574a0806cb51b555d297f38"
|
||||
dependencies = [
|
||||
"arrayvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
||||
|
||||
[[package]]
|
||||
name = "bitstream-io"
|
||||
version = "4.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7eff00be299a18769011411c9def0d827e8f2d7bf0c3dbf53633147a8867fd1f"
|
||||
dependencies = [
|
||||
"no_std_io2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
version = "0.10.4"
|
||||
@@ -54,6 +162,12 @@ dependencies = [
|
||||
"alloc-stdlib",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "built"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5c0e531d93d39c34eef561e929e8a7f86d77a5af08aac4f6d6e39976c51858e9"
|
||||
|
||||
[[package]]
|
||||
name = "bumpalo"
|
||||
version = "3.20.3"
|
||||
@@ -86,6 +200,18 @@ version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f1fe948ff07f4bd06c30984e69f5b4899c516a3ef74f34df92a2df2ab535495"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "877bf67ac8e52449eb2f9e98a344ea163beb70dd1f9eebe3cc5357dcfeaee4df"
|
||||
dependencies = [
|
||||
"find-msvc-tools",
|
||||
"jobserver",
|
||||
"libc",
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.5"
|
||||
@@ -173,6 +299,26 @@ version = "1.19.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be"
|
||||
|
||||
[[package]]
|
||||
name = "equator"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4711b213838dfee0117e3be6ac926007d7f433d7bbe33595975d4190cb07e6fc"
|
||||
dependencies = [
|
||||
"equator-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equator-macro"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "44f23cf4b44bfce11a86ace86f8a73ffdec849c9fd00a386a53d278bd9e81fb3"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fax"
|
||||
version = "0.2.7"
|
||||
@@ -188,6 +334,12 @@ dependencies = [
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "find-msvc-tools"
|
||||
version = "0.1.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.1.10"
|
||||
@@ -233,6 +385,29 @@ dependencies = [
|
||||
"version_check",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi 5.3.0",
|
||||
"wasip2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "300e883d756b2e4ec94e02791f39b04b522276138852cfc41d9fb7e904106099"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi 6.0.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gif"
|
||||
version = "0.14.2"
|
||||
@@ -283,12 +458,54 @@ dependencies = [
|
||||
"quick-error",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "imgref"
|
||||
version = "1.12.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6e44b0a4eaa4c82f441d50a963f2d5f05a787240aeee097597033e72accfd22f"
|
||||
|
||||
[[package]]
|
||||
name = "interpolate_name"
|
||||
version = "0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c34819042dc3d3971c46c2190835914dfbe0c3c13f61449b2997f4e9722dfa60"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itertools"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
|
||||
dependencies = [
|
||||
"either",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "itoa"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
|
||||
|
||||
[[package]]
|
||||
name = "jixel"
|
||||
version = "0.3.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "278a75e12caacec34be774d62ad05e45fc0b6a52d1f4e9f7fbc0209ecdf794f3"
|
||||
|
||||
[[package]]
|
||||
name = "jobserver"
|
||||
version = "0.1.35"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c00acbd29eabad4a2392fa0e921c874934dbbf4194312ad20f04a0ed67a3cb3"
|
||||
dependencies = [
|
||||
"getrandom 0.4.3",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "jpeg-decoder"
|
||||
version = "0.3.2"
|
||||
@@ -498,20 +715,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce5d3ddc6d3fa000eb1536d85e147bfe31aacaba692ed6a876f95cb7c855be78"
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-codecs"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=0dd6593d9db55a17ab559261bac4d766f015c345#0dd6593d9db55a17ab559261bac4d766f015c345"
|
||||
name = "libfuzzer-sys"
|
||||
version = "0.4.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a9fd2f41a1cba099f79a0b6b6c35656cf7c03351a7bae8ff0f28f25270f929d2"
|
||||
dependencies = [
|
||||
"arbitrary",
|
||||
"cc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-codecs"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"avif-serialize",
|
||||
"bytemuck",
|
||||
"image",
|
||||
"image-webp",
|
||||
"jixel",
|
||||
"jpeg-decoder",
|
||||
"jpeg-encoder",
|
||||
"jxl-oxide",
|
||||
"lightcraft-color",
|
||||
"lightcraft-geom",
|
||||
"lightcraft-raster",
|
||||
"moxcms 0.9.1",
|
||||
"png",
|
||||
"rav1e",
|
||||
"ravif",
|
||||
"rayon",
|
||||
"serde",
|
||||
"thiserror",
|
||||
@@ -522,8 +754,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-color"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=0dd6593d9db55a17ab559261bac4d766f015c345#0dd6593d9db55a17ab559261bac4d766f015c345"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"lightcraft-geom",
|
||||
"serde",
|
||||
@@ -531,8 +763,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-develop"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=0dd6593d9db55a17ab559261bac4d766f015c345#0dd6593d9db55a17ab559261bac4d766f015c345"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"lightcraft-color",
|
||||
"lightcraft-geom",
|
||||
@@ -543,8 +775,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-faces"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=0dd6593d9db55a17ab559261bac4d766f015c345#0dd6593d9db55a17ab559261bac4d766f015c345"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"matrixmultiply",
|
||||
"ndarray",
|
||||
@@ -557,16 +789,41 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-geom"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=0dd6593d9db55a17ab559261bac4d766f015c345#0dd6593d9db55a17ab559261bac4d766f015c345"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-inpaint"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-merge"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"lightcraft-codecs",
|
||||
"lightcraft-color",
|
||||
"lightcraft-geom",
|
||||
"lightcraft-meta",
|
||||
"lightcraft-raster",
|
||||
"lightcraft-raw",
|
||||
"lightcraft-scenes",
|
||||
"rayon",
|
||||
"serde",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-meta"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=0dd6593d9db55a17ab559261bac4d766f015c345#0dd6593d9db55a17ab559261bac4d766f015c345"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"lightcraft-geom",
|
||||
"lightcraft-tiff",
|
||||
@@ -576,12 +833,13 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-pipeline"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=0dd6593d9db55a17ab559261bac4d766f015c345#0dd6593d9db55a17ab559261bac4d766f015c345"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"lightcraft-color",
|
||||
"lightcraft-develop",
|
||||
"lightcraft-geom",
|
||||
"lightcraft-inpaint",
|
||||
"lightcraft-raster",
|
||||
"lightcraft-raw",
|
||||
"rayon",
|
||||
@@ -590,8 +848,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-raster"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=0dd6593d9db55a17ab559261bac4d766f015c345#0dd6593d9db55a17ab559261bac4d766f015c345"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"lightcraft-color",
|
||||
"lightcraft-geom",
|
||||
@@ -601,9 +859,10 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-raw"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=0dd6593d9db55a17ab559261bac4d766f015c345#0dd6593d9db55a17ab559261bac4d766f015c345"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"jpeg-encoder",
|
||||
"jxl-oxide",
|
||||
"lightcraft-color",
|
||||
"lightcraft-geom",
|
||||
@@ -618,15 +877,41 @@ dependencies = [
|
||||
"zune-jpeg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-scenes"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"lightcraft-color",
|
||||
"lightcraft-raster",
|
||||
"rayon",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lightcraft-tiff"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=0dd6593d9db55a17ab559261bac4d766f015c345#0dd6593d9db55a17ab559261bac4d766f015c345"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/storytold/lightcraft?rev=5fe74557eca64638b1f9015c9769f7e52a889fa2#5fe74557eca64638b1f9015c9769f7e52a889fa2"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
|
||||
|
||||
[[package]]
|
||||
name = "loop9"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fae87c125b03c1d2c0150c90365d7d6bcc53fb73a9acaef207d2d065860f062"
|
||||
dependencies = [
|
||||
"imgref",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "matrixmultiply"
|
||||
version = "0.3.11"
|
||||
@@ -637,6 +922,16 @@ dependencies = [
|
||||
"rawpointer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "maybe-rayon"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ea1f30cedd69f0a2954655f7188c6a834246d2bcf1e315e2ac40c4b24dc9519"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"rayon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.8.3"
|
||||
@@ -698,6 +993,46 @@ dependencies = [
|
||||
"rawpointer",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "new_debug_unreachable"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086"
|
||||
|
||||
[[package]]
|
||||
name = "no_std_io2"
|
||||
version = "0.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "418abd1b6d34fbf6cae440dc874771b0525a604428704c76e48b29a5e67b8003"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "nom"
|
||||
version = "8.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df9761775871bdef83bee530e60050f7e54b1105350d6884eb0fb4f46c2f9405"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "noop_proc_macro"
|
||||
version = "0.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0676bb32a98c1a483ce53e500a81ad9c3d5b3f7c920c28c24e9cb0980d0b5bc8"
|
||||
|
||||
[[package]]
|
||||
name = "num-bigint"
|
||||
version = "0.4.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c89e69e7e0f03bea5ef08013795c25018e101932225a656383bd384495ecc367"
|
||||
dependencies = [
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-complex"
|
||||
version = "0.4.6"
|
||||
@@ -707,6 +1042,17 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-derive"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-integer"
|
||||
version = "0.1.47"
|
||||
@@ -716,6 +1062,17 @@ dependencies = [
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-rational"
|
||||
version = "0.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f83d14da390562dca69fc84082e73e548e1ad308d24accdedd2720017cb37824"
|
||||
dependencies = [
|
||||
"num-bigint",
|
||||
"num-integer",
|
||||
"num-traits",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "num-traits"
|
||||
version = "0.2.19"
|
||||
@@ -731,15 +1088,31 @@ version = "1.21.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9f7c3e4beb33f85d45ae3e3a1792185706c8e16d043238c593331cc7cd313b50"
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "pastey"
|
||||
version = "0.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "35fb2e5f958ec131621fdd531e9fc186ed768cbe395337403ae56c17a74c68ec"
|
||||
|
||||
[[package]]
|
||||
name = "photoreport-engine"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"lightcraft-codecs",
|
||||
"lightcraft-color",
|
||||
"lightcraft-develop",
|
||||
"lightcraft-geom",
|
||||
"lightcraft-merge",
|
||||
"lightcraft-meta",
|
||||
"lightcraft-pipeline",
|
||||
"lightcraft-raster",
|
||||
"lightcraft-raw",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
@@ -808,6 +1181,15 @@ dependencies = [
|
||||
"portable-atomic",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ppv-lite86"
|
||||
version = "0.2.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
|
||||
dependencies = [
|
||||
"zerocopy",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.107"
|
||||
@@ -817,6 +1199,25 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "profiling"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d595e54a326bc53c1c197b32d295e14b169e3cfeaa8dc82b529f947fba6bcf5"
|
||||
dependencies = [
|
||||
"profiling-procmacros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "profiling-procmacros"
|
||||
version = "1.0.18"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4488a4a36b9a4ba6b9334a32a39971f77c1436ec82c38707bce707699cc3bbcb"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"syn 2.0.119",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pxfm"
|
||||
version = "0.1.30"
|
||||
@@ -847,6 +1248,97 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "5.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf"
|
||||
|
||||
[[package]]
|
||||
name = "rand"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b9ef1d0d795eb7d84685bca4f72f3649f064e6641543d3a8c415898726a57b41"
|
||||
dependencies = [
|
||||
"rand_chacha",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_chacha"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
|
||||
dependencies = [
|
||||
"ppv-lite86",
|
||||
"rand_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rand_core"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "76afc826de14238e6e8c374ddcc1fa19e374fd8dd986b0d2af0d02377261d83c"
|
||||
dependencies = [
|
||||
"getrandom 0.3.4",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rav1e"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "43b6dd56e85d9483277cde964fd1bdb0428de4fec5ebba7540995639a21cb32b"
|
||||
dependencies = [
|
||||
"aligned-vec",
|
||||
"arbitrary",
|
||||
"arg_enum_proc_macro",
|
||||
"arrayvec",
|
||||
"av-scenechange",
|
||||
"av1-grain",
|
||||
"bitstream-io",
|
||||
"built",
|
||||
"cfg-if",
|
||||
"interpolate_name",
|
||||
"itertools",
|
||||
"libc",
|
||||
"libfuzzer-sys",
|
||||
"log",
|
||||
"maybe-rayon",
|
||||
"new_debug_unreachable",
|
||||
"noop_proc_macro",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"paste",
|
||||
"profiling",
|
||||
"rand",
|
||||
"rand_chacha",
|
||||
"simd_helpers",
|
||||
"thiserror",
|
||||
"v_frame",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ravif"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e52310197d971b0f5be7fe6b57530dcd27beb35c1b013f29d66c1ad73fbbcc45"
|
||||
dependencies = [
|
||||
"avif-serialize",
|
||||
"imgref",
|
||||
"loop9",
|
||||
"quick-error",
|
||||
"rav1e",
|
||||
"rayon",
|
||||
"rgb",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rawpointer"
|
||||
version = "0.2.1"
|
||||
@@ -873,6 +1365,12 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rgb"
|
||||
version = "0.8.53"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "47b34b781b31e5d73e9fbc8689c70551fd1ade9a19e3e28cfec8580a79290cc4"
|
||||
|
||||
[[package]]
|
||||
name = "rustversion"
|
||||
version = "1.0.23"
|
||||
@@ -933,18 +1431,39 @@ dependencies = [
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f8fadd59c855ef2080decdef8ff161eb6661b86933c9d82e5ba29dc602a55aba"
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
|
||||
|
||||
[[package]]
|
||||
name = "simd_helpers"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "95890f873bec569a0362c235787f3aca6e1e887302ba4840839bcc6459c42da6"
|
||||
dependencies = [
|
||||
"quote",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.119"
|
||||
@@ -1032,12 +1551,32 @@ version = "1.0.26"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d245f478577f809a851594d02313b640fb437e0bb33866753cff937863096954"
|
||||
|
||||
[[package]]
|
||||
name = "v_frame"
|
||||
version = "0.3.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "666b7727c8875d6ab5db9533418d7c764233ac9c0cff1d469aec8fa127597be2"
|
||||
dependencies = [
|
||||
"aligned-vec",
|
||||
"num-traits",
|
||||
"wasm-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.4+wasi-0.2.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b67efb37e106e55ce722a510d6b5f9c17f083e5fc79afc2badeb12cc313d9487"
|
||||
dependencies = [
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.129"
|
||||
@@ -1099,6 +1638,18 @@ version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.57.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1ebf944e87a7c253233ad6766e082e3cd714b5d03812acc24c318f549614536e"
|
||||
|
||||
[[package]]
|
||||
name = "y4m"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7a5a4b21e1a62b67a2970e6831bc091d7b87e119e7f9791aef9702e3bef04448"
|
||||
|
||||
[[package]]
|
||||
name = "zerocopy"
|
||||
version = "0.8.62"
|
||||
|
||||
+10
-6
@@ -10,12 +10,16 @@ publish = false
|
||||
|
||||
[workspace.dependencies]
|
||||
# LightCraft is consumed, never forked. Bump `rev` deliberately and run the reference-image tests.
|
||||
lightcraft-develop = { git = "https://github.com/storytold/lightcraft", rev = "0dd6593d9db55a17ab559261bac4d766f015c345" }
|
||||
lightcraft-codecs = { git = "https://github.com/storytold/lightcraft", rev = "0dd6593d9db55a17ab559261bac4d766f015c345", default-features = false }
|
||||
lightcraft-pipeline = { git = "https://github.com/storytold/lightcraft", rev = "0dd6593d9db55a17ab559261bac4d766f015c345" }
|
||||
lightcraft-raster = { git = "https://github.com/storytold/lightcraft", rev = "0dd6593d9db55a17ab559261bac4d766f015c345" }
|
||||
lightcraft-geom = { git = "https://github.com/storytold/lightcraft", rev = "0dd6593d9db55a17ab559261bac4d766f015c345" }
|
||||
lightcraft-faces = { git = "https://github.com/storytold/lightcraft", rev = "0dd6593d9db55a17ab559261bac4d766f015c345" }
|
||||
lightcraft-develop = { git = "https://github.com/storytold/lightcraft", rev = "5fe74557eca64638b1f9015c9769f7e52a889fa2" }
|
||||
lightcraft-codecs = { git = "https://github.com/storytold/lightcraft", rev = "5fe74557eca64638b1f9015c9769f7e52a889fa2", default-features = false }
|
||||
lightcraft-pipeline = { git = "https://github.com/storytold/lightcraft", rev = "5fe74557eca64638b1f9015c9769f7e52a889fa2" }
|
||||
lightcraft-raster = { git = "https://github.com/storytold/lightcraft", rev = "5fe74557eca64638b1f9015c9769f7e52a889fa2" }
|
||||
lightcraft-geom = { git = "https://github.com/storytold/lightcraft", rev = "5fe74557eca64638b1f9015c9769f7e52a889fa2" }
|
||||
lightcraft-faces = { git = "https://github.com/storytold/lightcraft", rev = "5fe74557eca64638b1f9015c9769f7e52a889fa2" }
|
||||
lightcraft-merge = { git = "https://github.com/storytold/lightcraft", rev = "5fe74557eca64638b1f9015c9769f7e52a889fa2" }
|
||||
lightcraft-raw = { git = "https://github.com/storytold/lightcraft", rev = "5fe74557eca64638b1f9015c9769f7e52a889fa2" }
|
||||
lightcraft-color = { git = "https://github.com/storytold/lightcraft", rev = "5fe74557eca64638b1f9015c9769f7e52a889fa2" }
|
||||
lightcraft-meta = { git = "https://github.com/storytold/lightcraft", rev = "5fe74557eca64638b1f9015c9769f7e52a889fa2" }
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
thiserror = "2"
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "organizations" ADD COLUMN "real_estate_enabled" BOOLEAN NOT NULL DEFAULT false;
|
||||
@@ -62,6 +62,8 @@ model Organization {
|
||||
/// Face recognition is biometric data: off unless enabled with a recorded legal basis.
|
||||
biometricsEnabled Boolean @default(false) @map("biometrics_enabled")
|
||||
biometricsLegalBasis String? @map("biometrics_legal_basis")
|
||||
/// Interior brackets. Off: the area is hidden and its routes refuse work. Sports ingest is unchanged.
|
||||
realEstateEnabled Boolean @default(false) @map("real_estate_enabled")
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
updatedAt DateTime @updatedAt @map("updated_at")
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import { registerUploadRoutes } from "./library/uploads.js";
|
||||
import { IngestService } from "./ingest/service.js";
|
||||
import { CorrectionRecorder } from "./autopilot/learning.js";
|
||||
import { registerAutopilotRoutes } from "./autopilot/routes.js";
|
||||
import { registerRealEstateRoutes } from "./realestate/routes.js";
|
||||
import { registerDevelopRoutes } from "./develop/routes.js";
|
||||
import { DevelopService } from "./develop/service.js";
|
||||
import { registerFaceRoutes } from "./faces/routes.js";
|
||||
@@ -196,6 +197,7 @@ export async function buildApp({ config, db, realtime, fetchImpl, reporter: give
|
||||
const develop = new DevelopService({ db, storage, signer, broadcaster, log: app.log, onHumanEdit: (id) => corrections.schedule(id) });
|
||||
await registerDevelopRoutes(app, { db, sessions, develop });
|
||||
await registerAutopilotRoutes(app, { db, sessions });
|
||||
await registerRealEstateRoutes(app, { db, sessions });
|
||||
// Shop: the public sites read galleries and place orders; the worker renders the bought files.
|
||||
const print = new PrintService({ db, storage, signer, broadcaster, log: app.log, secret: config.JWT_SECRET, secrets, stripeApiUrl: config.STRIPE_API_URL, ...(fetchImpl && { fetchImpl }) });
|
||||
const notifications = new Notifications(db, (err) => app.log.warn({ err }, "notifications: not written"));
|
||||
|
||||
@@ -5,6 +5,10 @@ import exifr from "exifr";
|
||||
* IPTC already in an incoming file (camera presets, or a photo captioned in Lightroom/Photo Mechanic).
|
||||
* XMP is read first: it is always UTF-8. IIM is the fallback, and Lightroom and Photo Mechanic on the Mac write
|
||||
* it in Mac Roman without saying so ("Pavilh‹o" for "Pavilhão"), which is repaired here.
|
||||
*
|
||||
* LightCraft's metadata reader is what the engine uses for capture (time, exposure, camera). It does not
|
||||
* keep the Photo Mechanic pad (headline, event, credit, people, contacts, job id and the rest), so this
|
||||
* reader stays for those fields.
|
||||
*/
|
||||
|
||||
// Mac Roman 0x80–0x9F (the range that betrays it: in Latin-1 these are control characters).
|
||||
|
||||
@@ -6,6 +6,12 @@ import { type FocusHint, focusFromTags } from "./focus.js";
|
||||
* The camera details Photo Mechanic shows beyond the ones with their own column (stored in `photos.exif`), for
|
||||
* its variables: {comp}, {flash}, {meteringmode}, {program}, {white}, {lens35}, {owner}, {artist}... Readable
|
||||
* strings, as Photo Mechanic writes them.
|
||||
*
|
||||
* Capture time and exposure are also read by the develop engine through LightCraft (`photoreport_engine::capture`:
|
||||
* EXIF, then IPTC, then XMP, including CR3). JPEG ingest stays on this reader: it runs in process, event routing
|
||||
* assumes Lisbon when the camera wrote no UTC offset, and these variables include owner, firmware, colour space,
|
||||
* resolution and the focus SubjectArea, which that metadata struct does not carry. Its focus point covers two
|
||||
* Sony bodies only.
|
||||
*/
|
||||
export type CameraExtra = Pick<
|
||||
PmPhoto,
|
||||
|
||||
@@ -30,7 +30,13 @@ export async function registerMeRoutes(app: FastifyInstance, deps: { db: Db; ses
|
||||
user: { id: user.id, email: user.email, name: user.name, locale: user.locale },
|
||||
memberships: user.memberships.map((m) => ({
|
||||
role: m.role,
|
||||
organization: { id: m.organization.id, slug: m.organization.slug, name: m.organization.name, mode: m.organization.mode },
|
||||
organization: {
|
||||
id: m.organization.id,
|
||||
slug: m.organization.slug,
|
||||
name: m.organization.name,
|
||||
mode: m.organization.mode,
|
||||
realEstateEnabled: m.organization.realEstateEnabled,
|
||||
},
|
||||
})),
|
||||
preferences: { editorModules: user.preferences?.editorModules ?? ["crop", "basic"] },
|
||||
};
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
import { groupBrackets, type BracketFrame } from "@photoreport/metadata";
|
||||
import type { FastifyInstance } from "fastify";
|
||||
import { z } from "zod";
|
||||
import { requireAuth, requireMembership } from "../auth/guard.js";
|
||||
import type { SessionService } from "../auth/sessions.js";
|
||||
import type { Db } from "../db.js";
|
||||
import { conflict } from "../lib/errors.js";
|
||||
|
||||
const OrgParams = z.object({ orgId: z.uuid() });
|
||||
const SettingBody = z.object({ enabled: z.boolean() });
|
||||
|
||||
const optionalText = z.string().trim().max(300).nullable().optional();
|
||||
const optionalNumber = z.number().nullable().optional();
|
||||
|
||||
const FrameBody = z.object({
|
||||
id: z.string().trim().min(1).max(400),
|
||||
fileName: optionalText,
|
||||
capturedAt: z.iso.datetime().nullable().optional(),
|
||||
cameraSerial: optionalText,
|
||||
cameraMake: optionalText,
|
||||
cameraModel: optionalText,
|
||||
focalLength: optionalNumber,
|
||||
aperture: optionalNumber,
|
||||
iso: optionalNumber,
|
||||
width: optionalNumber,
|
||||
height: optionalNumber,
|
||||
exposureBias: optionalNumber,
|
||||
exposureTime: optionalNumber,
|
||||
});
|
||||
|
||||
const GroupBody = z.object({ frames: z.array(FrameBody).max(4000) });
|
||||
|
||||
/**
|
||||
* The interior-bracket area. It never touches sports ingest: files stay on the photographer's
|
||||
* computer and only the exposure metadata is sent, to be grouped. Merging the frames is later.
|
||||
*/
|
||||
export async function registerRealEstateRoutes(app: FastifyInstance, deps: { db: Db; sessions: SessionService }) {
|
||||
const { db } = deps;
|
||||
const authenticate = requireAuth(deps.sessions);
|
||||
|
||||
app.get("/v1/orgs/:orgId/real-estate", { preHandler: authenticate }, async (req) => {
|
||||
const { orgId } = OrgParams.parse(req.params);
|
||||
await requireMembership(db, req, orgId, "PHOTOGRAPHER");
|
||||
const org = await db.organization.findUniqueOrThrow({ where: { id: orgId }, select: { realEstateEnabled: true } });
|
||||
return { enabled: org.realEstateEnabled };
|
||||
});
|
||||
|
||||
/** Owners show or hide the area. Hiding it does not delete anything already made. */
|
||||
app.put("/v1/orgs/:orgId/real-estate", { preHandler: authenticate }, async (req) => {
|
||||
const { orgId } = OrgParams.parse(req.params);
|
||||
const body = SettingBody.parse(req.body);
|
||||
await requireMembership(db, req, orgId, "OWNER");
|
||||
const org = await db.organization.update({ where: { id: orgId }, data: { realEstateEnabled: body.enabled }, select: { realEstateEnabled: true } });
|
||||
return { enabled: org.realEstateEnabled };
|
||||
});
|
||||
|
||||
/** Groups a shoot into one stack per angle. Refuses while the area is hidden. */
|
||||
app.post("/v1/orgs/:orgId/real-estate/groups", { preHandler: authenticate }, async (req) => {
|
||||
const { orgId } = OrgParams.parse(req.params);
|
||||
await requireMembership(db, req, orgId, "PHOTOGRAPHER");
|
||||
const org = await db.organization.findUniqueOrThrow({ where: { id: orgId }, select: { realEstateEnabled: true } });
|
||||
if (!org.realEstateEnabled) throw conflict("real_estate_disabled");
|
||||
const body = GroupBody.parse(req.body);
|
||||
return groupBrackets(body.frames.map(finiteFrame));
|
||||
});
|
||||
}
|
||||
|
||||
function finite(value: number | null | undefined): number | null {
|
||||
if (value == null || !Number.isFinite(value)) return null;
|
||||
return value;
|
||||
}
|
||||
|
||||
function finiteFrame(frame: z.infer<typeof FrameBody>): BracketFrame {
|
||||
return {
|
||||
id: frame.id,
|
||||
fileName: frame.fileName ?? null,
|
||||
capturedAt: frame.capturedAt ?? null,
|
||||
cameraSerial: frame.cameraSerial ?? null,
|
||||
cameraMake: frame.cameraMake ?? null,
|
||||
cameraModel: frame.cameraModel ?? null,
|
||||
focalLength: finite(frame.focalLength),
|
||||
aperture: finite(frame.aperture),
|
||||
iso: finite(frame.iso),
|
||||
width: finite(frame.width),
|
||||
height: finite(frame.height),
|
||||
exposureBias: finite(frame.exposureBias),
|
||||
exposureTime: finite(frame.exposureTime),
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
import { afterAll, beforeAll, beforeEach, describe, expect, it } from "vitest";
|
||||
import { bearer, createTestApp, login, resetDb, seedUser, type TestContext } from "./helpers.js";
|
||||
|
||||
let ctx: TestContext;
|
||||
beforeAll(async () => {
|
||||
ctx = await createTestApp();
|
||||
});
|
||||
afterAll(async () => {
|
||||
await ctx.app.close();
|
||||
await ctx.db.$disconnect();
|
||||
});
|
||||
beforeEach(() => resetDb(ctx.db));
|
||||
|
||||
const at = (ms: number) => new Date(Date.parse("2026-10-21T10:00:00.000Z") + ms).toISOString();
|
||||
|
||||
function shot(id: string, bias: number, ms: number) {
|
||||
return {
|
||||
id,
|
||||
fileName: `${id}.CR3`,
|
||||
capturedAt: at(ms),
|
||||
cameraSerial: "body",
|
||||
focalLength: 16,
|
||||
aperture: 8,
|
||||
iso: 100,
|
||||
exposureBias: bias,
|
||||
exposureTime: 0.01,
|
||||
};
|
||||
}
|
||||
|
||||
describe("real estate", () => {
|
||||
it("stays off until the owner turns it on, and then groups a bracket without taking the files", async () => {
|
||||
const { org } = await seedUser(ctx.db, "[email protected]", { org: "casa", role: "OWNER" });
|
||||
await seedUser(ctx.db, "[email protected]", { org: "casa", role: "PHOTOGRAPHER" });
|
||||
await seedUser(ctx.db, "[email protected]", { org: "casa", role: "CLIENT" });
|
||||
const owner = await login(ctx.app, "[email protected]");
|
||||
const photographer = await login(ctx.app, "[email protected]");
|
||||
const client = await login(ctx.app, "[email protected]");
|
||||
const orgId = org!.id;
|
||||
const url = `/v1/orgs/${orgId}/real-estate`;
|
||||
|
||||
const me = await ctx.app.inject({ method: "GET", url: "/v1/me", headers: bearer(owner.body.accessToken) });
|
||||
expect(me.json().memberships[0].organization.realEstateEnabled).toBe(false);
|
||||
|
||||
const hidden = await ctx.app.inject({
|
||||
method: "POST",
|
||||
url: `${url}/groups`,
|
||||
headers: bearer(owner.body.accessToken),
|
||||
payload: { frames: [shot("a", -2, 0), shot("b", 0, 200), shot("c", 2, 400)] },
|
||||
});
|
||||
expect(hidden.statusCode).toBe(409);
|
||||
expect(hidden.json().error).toBe("real_estate_disabled");
|
||||
|
||||
const asPhotographer = await ctx.app.inject({
|
||||
method: "PUT",
|
||||
url,
|
||||
headers: bearer(photographer.body.accessToken),
|
||||
payload: { enabled: true },
|
||||
});
|
||||
expect(asPhotographer.statusCode).toBe(403);
|
||||
|
||||
const on = await ctx.app.inject({ method: "PUT", url, headers: bearer(owner.body.accessToken), payload: { enabled: true } });
|
||||
expect(on.json()).toEqual({ enabled: true });
|
||||
|
||||
const asClient = await ctx.app.inject({
|
||||
method: "POST",
|
||||
url: `${url}/groups`,
|
||||
headers: bearer(client.body.accessToken),
|
||||
payload: { frames: [shot("a", -2, 0)] },
|
||||
});
|
||||
expect(asClient.statusCode).toBe(403);
|
||||
|
||||
const grouped = await ctx.app.inject({
|
||||
method: "POST",
|
||||
url: `${url}/groups`,
|
||||
headers: bearer(photographer.body.accessToken),
|
||||
payload: {
|
||||
frames: [shot("a", -2, 0), shot("b", 0, 200), shot("c", 2, 400), shot("solo", 0, 30_000)],
|
||||
},
|
||||
});
|
||||
expect(grouped.statusCode).toBe(200);
|
||||
expect(grouped.json()).toEqual({ stacks: [{ frameIds: ["a", "b", "c"] }], aside: ["solo"] });
|
||||
});
|
||||
});
|
||||
@@ -16,6 +16,7 @@ import { LoginPage } from "./pages/LoginPage.js";
|
||||
import { MembersPage } from "./pages/MembersPage.js";
|
||||
import { MetadataPage } from "./pages/MetadataPage.js";
|
||||
import { PreferencesPage } from "./pages/PreferencesPage.js";
|
||||
import { RealEstatePage } from "./pages/RealEstatePage.js";
|
||||
import { Shell } from "./pages/Shell.js";
|
||||
|
||||
function Gate() {
|
||||
@@ -40,6 +41,7 @@ function Gate() {
|
||||
<Route path="members" element={<MembersPage />} />
|
||||
<Route path="preferences" element={<PreferencesPage />} />
|
||||
<Route path="help" element={<HelpPage />} />
|
||||
<Route path="real-estate" element={<RealEstatePage />} />
|
||||
<Route path="*" element={<p className="p-6 text-sm text-muted">{t.notFound}</p>} />
|
||||
</Route>
|
||||
<Route path="/login" element={<Navigate to="/" replace />} />
|
||||
|
||||
@@ -19,14 +19,30 @@ export interface WasmPhoto {
|
||||
free(): void;
|
||||
}
|
||||
|
||||
export interface BracketJob {
|
||||
push(bytes: Uint8Array): void;
|
||||
merge(maxEdge: number): BracketMerge;
|
||||
free(): void;
|
||||
}
|
||||
|
||||
export interface BracketMerge {
|
||||
readonly width: number;
|
||||
readonly height: number;
|
||||
jpeg(): Uint8Array;
|
||||
free(): void;
|
||||
}
|
||||
|
||||
export interface EngineModule {
|
||||
default(init?: { module_or_path: string }): Promise<unknown>;
|
||||
/** Capture metadata JSON from LightCraft. `{}` when the file has none. */
|
||||
readCaptureMeta(bytes: Uint8Array): string;
|
||||
controls(): string;
|
||||
defaultSettings(): string;
|
||||
apply(settings: string, command: string): string;
|
||||
value(settings: string, id: string): number;
|
||||
isUnedited(settings: string): boolean;
|
||||
Photo: new (bytes: Uint8Array, maxEdge: number) => WasmPhoto;
|
||||
BracketJob: new () => BracketJob;
|
||||
}
|
||||
|
||||
const BASE = `${import.meta.env.BASE_URL ?? "/"}engine/`;
|
||||
|
||||
@@ -205,6 +205,40 @@ export const t = {
|
||||
disable: "Desligar",
|
||||
enabled: "Ligado",
|
||||
},
|
||||
realEstate: {
|
||||
nav: "Imobiliário",
|
||||
title: "Imobiliário",
|
||||
setting: "Imobiliário",
|
||||
settingHelp: "Zona à parte para interiores em bracket. Desligada, desaparece do menu. O FTP e a biblioteca de jogos não mudam.",
|
||||
enable: "Ligar",
|
||||
disable: "Desligar",
|
||||
enabled: "Ligado",
|
||||
off: "Desligado",
|
||||
intro: "Larga os ficheiros de um imóvel. Cada ângulo são várias exposições da mesma posição, normalmente três. Os ficheiros ficam neste computador; para agrupar só seguem os dados de exposição.",
|
||||
step: "Cada ângulo é fundido aqui, neste computador, pelo motor de imagem. A janela vem da exposição escura e a sala da clara.",
|
||||
fusing: "A fundir este ângulo…",
|
||||
fuseFailed: "Não deu para fundir este ângulo.",
|
||||
previewAlt: (n: number) => `Ângulo ${n} fundido`,
|
||||
choose: "Escolher ficheiros",
|
||||
chooseFolder: "Escolher pasta",
|
||||
dropHint: "ou larga uma pasta aqui",
|
||||
reading: (done: number, total: number) => `A ler ${done} de ${total}…`,
|
||||
noPhotos: "Não há fotografias nesta seleção. Um ficheiro XMP só acompanha o raw.",
|
||||
support: (n: number) => (n === 1 ? "1 ficheiro de apoio (XMP e semelhantes) não é uma fotografia." : `${n} ficheiros de apoio (XMP e semelhantes) não são fotografias.`),
|
||||
asideMore: (n: number) => `e mais ${n}`,
|
||||
stacks: (n: number) => (n === 1 ? "1 ângulo" : `${n} ângulos`),
|
||||
aside: (n: number) => (n === 1 ? "1 fotografia fica de fora" : `${n} fotografias ficam de fora`),
|
||||
asideHelp: "Não entram num bracket de pelo menos três exposições, com a luz e a sombra afastadas.",
|
||||
angle: (n: number, frames: number) => `Ângulo ${n} · ${frames === 1 ? "1 exposição" : `${frames} exposições`}`,
|
||||
bias: (value: string) => `${value} EV`,
|
||||
noBias: "exposição sem compensação",
|
||||
noExposure: "sem dados de exposição",
|
||||
disabled: "O imobiliário está desligado. O proprietário liga-o em Preferências.",
|
||||
none: "Nenhum ângulo com três ou mais exposições.",
|
||||
errors: {
|
||||
real_estate_disabled: "O imobiliário está desligado nesta organização.",
|
||||
} as Record<string, string>,
|
||||
},
|
||||
uploading: (done: number, total: number) => `A enviar ${done} de ${total}`,
|
||||
uploaded: (n: number) => (n === 1 ? "1 foto enviada" : `${n} fotos enviadas`),
|
||||
uploadFailed: (n: number) => `${n} com erro`,
|
||||
|
||||
@@ -114,4 +114,25 @@ describe("library store", () => {
|
||||
expect(s.photos.map((p) => p.id)).toEqual(["a", "live"]);
|
||||
expect(s.loading).toBe(false);
|
||||
});
|
||||
|
||||
it("replaces expired file urls from the cache and keeps a mark made while the list was loading", () => {
|
||||
const stale = { thumb: "/v1/files/photos/a/thumb?exp=1&v=2", preview: "/old-preview?v=2", source: "/old-source" };
|
||||
const fresh = { thumb: "/v1/files/photos/a/thumb?exp=9&v=2", preview: "/new-preview?v=2", source: "/new-source" };
|
||||
let s = libraryReducer(initialLibrary, { type: "load", scope: "e1" });
|
||||
s = libraryReducer(s, { type: "loaded", scope: "e1", photos: [photo("a", "1", { urls: stale })], done: false });
|
||||
s = libraryReducer(s, { type: "patch", ids: ["a"], patch: { flag: "PICK" } });
|
||||
s = libraryReducer(s, { type: "loaded", scope: "e1", photos: [photo("a", "1", { urls: fresh, flag: "NONE" })], done: true, drop: ["a"] });
|
||||
expect(s.photos[0]).toMatchObject({ flag: "PICK", urls: fresh });
|
||||
});
|
||||
|
||||
it("does not roll a thumbnail back to an older render that the list still has", () => {
|
||||
const shown = { thumb: "/thumb?v=4", preview: "/preview?v=4", source: "/source" };
|
||||
const older = { thumb: "/thumb?v=3", preview: "/preview?v=3", source: "/source" };
|
||||
let s = libraryReducer(initialLibrary, { type: "load", scope: "e1" });
|
||||
s = libraryReducer(s, { type: "loaded", scope: "e1", photos: [photo("a", "1", { urls: older })], done: false });
|
||||
s = libraryReducer(s, { type: "message", message: { type: "photo.rendered", photoId: "a", renderedSeq: 4, urls: { thumb: shown.thumb, preview: shown.preview } } });
|
||||
s = libraryReducer(s, { type: "loaded", scope: "e1", photos: [photo("a", "1", { urls: older })], done: true, drop: ["a"] });
|
||||
expect(s.photos[0]!.urls.thumb).toBe(shown.thumb);
|
||||
expect(s.photos[0]!.urls.preview).toBe(shown.preview);
|
||||
});
|
||||
});
|
||||
@@ -44,6 +44,29 @@ function inScope(scope: string | null, photo: PhotoSummary): boolean {
|
||||
return scope === "inbox" ? photo.eventId === null : photo.eventId === scope;
|
||||
}
|
||||
|
||||
/** Edit version in a signed file URL (`v`). A render that arrived while the list was loading must not be rolled back. */
|
||||
function renderedVersion(url: string): number {
|
||||
const match = /[?&]v=(\d+)/.exec(url);
|
||||
if (!match) return 0;
|
||||
return Number(match[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* The folder is drawn from the last visit before the network answers. Marks made in that moment stay,
|
||||
* but the signed file URLs from that visit expire, so the server's signatures take their place.
|
||||
*/
|
||||
function withFreshFileUrls(current: PhotoSummary, incoming: PhotoSummary | undefined): PhotoSummary {
|
||||
if (!incoming) return current;
|
||||
let next = current;
|
||||
if (current.status !== "READY" && incoming.status !== current.status) {
|
||||
next = { ...next, status: incoming.status };
|
||||
if (incoming.error) next = { ...next, error: incoming.error };
|
||||
}
|
||||
if (renderedVersion(incoming.urls.thumb) < renderedVersion(current.urls.thumb)) return next;
|
||||
if (current.urls.thumb === incoming.urls.thumb && current.urls.preview === incoming.urls.preview && current.urls.source === incoming.urls.source) return next;
|
||||
return { ...next, urls: incoming.urls };
|
||||
}
|
||||
|
||||
/** The server's copy replaces a local photo: what was done to it here stays (it is being sent too). */
|
||||
function replaceLocal(state: LibraryState, local: PhotoSummary, server: PhotoSummary): LibraryState {
|
||||
const keep: Partial<PhotoSummary> = {
|
||||
@@ -67,10 +90,11 @@ export function libraryReducer(state: LibraryState, action: LibraryAction): Libr
|
||||
// A cached folder is shown first. Once the server has answered, photos that were only in that cache
|
||||
// (they have since moved to another event) leave. Anything that arrived meanwhile stays.
|
||||
const drop = new Set(action.drop ?? []);
|
||||
const incoming = new Set(action.photos.map((p) => p.id));
|
||||
const incoming = new Map(action.photos.map((p) => [p.id, p]));
|
||||
const prior = drop.size ? state.photos.filter((p) => !drop.has(p.id) || incoming.has(p.id)) : state.photos;
|
||||
const seen = new Set(prior.map((p) => p.id));
|
||||
const photos = [...prior, ...action.photos.filter((p) => !seen.has(p.id))];
|
||||
const refreshed = prior.map((p) => withFreshFileUrls(p, incoming.get(p.id)));
|
||||
const seen = new Set(refreshed.map((p) => p.id));
|
||||
const photos = [...refreshed, ...action.photos.filter((p) => !seen.has(p.id))];
|
||||
// The active photo from another module (or the last visit): selected as soon as its page arrives.
|
||||
if (state.wanted && photos.some((p) => p.id === state.wanted)) {
|
||||
const id = state.wanted;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { DEFAULT_MODULES, MODULES, type Module } from "@photoreport/contracts";
|
||||
import { ApiError } from "@photoreport/sdk";
|
||||
import { useState } from "react";
|
||||
import { useAuth } from "../auth.js";
|
||||
import { LocalCatalog } from "../desktop/LocalCatalog.js";
|
||||
@@ -11,9 +12,12 @@ import { PageHeader } from "./Shell.js";
|
||||
const CHOOSABLE = MODULES.filter((m) => m !== "advanced");
|
||||
|
||||
export function PreferencesPage() {
|
||||
const { api, me, reload } = useAuth();
|
||||
const { api, me, reload, organization, role } = useAuth();
|
||||
const [selected, setSelected] = useState<Module[]>(me?.preferences.editorModules ?? [...DEFAULT_MODULES]);
|
||||
const [status, setStatus] = useState<"idle" | "saved" | "error">("idle");
|
||||
const [realEstateError, setRealEstateError] = useState<string | null>(null);
|
||||
const [realEstateBusy, setRealEstateBusy] = useState(false);
|
||||
const realEstateOn = organization?.realEstateEnabled === true;
|
||||
|
||||
const toggle = async (module: Module) => {
|
||||
const next = selected.includes(module) ? selected.filter((m) => m !== module) : [...selected, module];
|
||||
@@ -52,6 +56,43 @@ export function PreferencesPage() {
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
{role === "OWNER" && organization && (
|
||||
<section className="max-w-2xl px-6 pb-6">
|
||||
<div className="border border-line bg-panel">
|
||||
<div className="panel-head">
|
||||
<span>{t.realEstate.setting}</span>
|
||||
<span className={realEstateOn ? "text-ok" : "text-faint"}>{realEstateOn ? t.realEstate.enabled : t.realEstate.off}</span>
|
||||
</div>
|
||||
<div className="space-y-3 p-4">
|
||||
<p className="text-[13px] text-muted">{t.realEstate.settingHelp}</p>
|
||||
{realEstateError && <p className="text-[12px] text-danger">{realEstateError}</p>}
|
||||
<div className="flex justify-end">
|
||||
<button
|
||||
disabled={realEstateBusy}
|
||||
onClick={() => {
|
||||
setRealEstateBusy(true);
|
||||
setRealEstateError(null);
|
||||
void (async () => {
|
||||
try {
|
||||
await api.setRealEstate(organization.id, !realEstateOn);
|
||||
await reload();
|
||||
} catch (err) {
|
||||
const code = err instanceof ApiError ? err.code : "";
|
||||
setRealEstateError(t.realEstate.errors[code] ?? t.unexpectedError);
|
||||
} finally {
|
||||
setRealEstateBusy(false);
|
||||
}
|
||||
})();
|
||||
}}
|
||||
className="h-8 border border-black bg-cell px-4 text-[13px] hover:bg-cell-on disabled:opacity-50"
|
||||
>
|
||||
{realEstateOn ? t.realEstate.disable : t.realEstate.enable}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)}
|
||||
{isDesktop() && <LocalCatalog />}
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
import type { BracketFrame } from "@photoreport/metadata";
|
||||
import { groupBrackets } from "@photoreport/metadata";
|
||||
import type { ApiClient, Me, Organization } from "@photoreport/sdk";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { App } from "../App.js";
|
||||
|
||||
vi.mock("../library/realtime.js", () => ({
|
||||
useLibraryLive: () => "live",
|
||||
onSocketLive: () => () => undefined,
|
||||
}));
|
||||
vi.mock("../realestate/fuse.js", () => ({
|
||||
fuseBracket: () => Promise.resolve(new Blob([Uint8Array.from([0xff, 0xd8])], { type: "image/jpeg" })),
|
||||
}));
|
||||
|
||||
const staged = vi.hoisted(() => ({ frames: new Map<string, BracketFrame>() }));
|
||||
|
||||
vi.mock("../realestate/readFrame.js", async () => {
|
||||
const actual = await vi.importActual<typeof import("../realestate/readFrame.js")>("../realestate/readFrame.js");
|
||||
return {
|
||||
...actual,
|
||||
readBracketFile: (file: File) => Promise.resolve(staged.frames.get(file.name) ?? { id: file.name, fileName: file.name }),
|
||||
};
|
||||
});
|
||||
|
||||
const org = (realEstateEnabled: boolean): Organization => ({ id: "o1", slug: "fpa", name: "FPA", mode: "AGENCY", realEstateEnabled });
|
||||
|
||||
function me(role: Me["memberships"][number]["role"], realEstateEnabled: boolean): Me {
|
||||
return {
|
||||
user: { id: "u1", email: "[email protected]", name: "Ana", locale: "pt-PT" },
|
||||
memberships: [{ role, organization: org(realEstateEnabled) }],
|
||||
preferences: { editorModules: ["crop", "basic"] },
|
||||
};
|
||||
}
|
||||
|
||||
function fakeApi(who: Me, overrides: Partial<Record<keyof ApiClient, unknown>> = {}): ApiClient {
|
||||
return {
|
||||
client: "web",
|
||||
resume: vi.fn().mockResolvedValue(true),
|
||||
me: vi.fn().mockResolvedValue(who),
|
||||
listEvents: vi.fn().mockResolvedValue({ events: [], inboxCount: 0 }),
|
||||
listPhotos: vi.fn().mockResolvedValue({ photos: [], total: 0 }),
|
||||
absolute: (path: string) => path,
|
||||
groupRealEstate: vi.fn(async (_orgId: string, frames: BracketFrame[]) => groupBrackets(frames)),
|
||||
setRealEstate: vi.fn().mockResolvedValue({ enabled: true }),
|
||||
...overrides,
|
||||
} as unknown as ApiClient;
|
||||
}
|
||||
|
||||
const at = (ms: number) => new Date(Date.parse("2026-10-21T10:00:00.000Z") + ms).toISOString();
|
||||
|
||||
function shot(name: string, bias: number, ms: number): BracketFrame {
|
||||
return {
|
||||
id: name,
|
||||
fileName: name,
|
||||
capturedAt: at(ms),
|
||||
cameraSerial: "body",
|
||||
focalLength: 16,
|
||||
aperture: 8,
|
||||
iso: 100,
|
||||
exposureBias: bias,
|
||||
exposureTime: 0.01,
|
||||
};
|
||||
}
|
||||
|
||||
describe("real estate area", () => {
|
||||
beforeEach(() => {
|
||||
URL.createObjectURL = () => "blob:fused";
|
||||
URL.revokeObjectURL = () => undefined;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
staged.frames.clear();
|
||||
window.history.pushState({}, "", "/");
|
||||
});
|
||||
|
||||
it("stays out of the menu until the organization turns it on", async () => {
|
||||
render(<App api={fakeApi(me("PHOTOGRAPHER", false))} />);
|
||||
expect(await screen.findByText(/Ainda não chegaram fotografias/)).toBeTruthy();
|
||||
expect(screen.queryByRole("link", { name: "Imobiliário" })).toBeNull();
|
||||
});
|
||||
|
||||
it("groups a dropped bracket and leaves the loose frame out", async () => {
|
||||
staged.frames.set("a.cr3", shot("a.cr3", -2, 0));
|
||||
staged.frames.set("b.cr3", shot("b.cr3", 0, 200));
|
||||
staged.frames.set("c.cr3", shot("c.cr3", 2, 400));
|
||||
staged.frames.set("solo.cr3", shot("solo.cr3", 0, 30_000));
|
||||
const api = fakeApi(me("PHOTOGRAPHER", true));
|
||||
render(<App api={api} />);
|
||||
await userEvent.click(await screen.findByRole("link", { name: "Imobiliário" }));
|
||||
const input = screen.getByLabelText("Escolher ficheiros");
|
||||
await userEvent.upload(input, [new File(["a"], "a.cr3"), new File(["b"], "b.cr3"), new File(["c"], "c.cr3"), new File(["s"], "solo.cr3")]);
|
||||
expect(await screen.findByText("1 ângulo")).toBeTruthy();
|
||||
expect(screen.getByText("Ângulo 1 · 3 exposições")).toBeTruthy();
|
||||
expect(await screen.findByRole("img", { name: "Ângulo 1 fundido" })).toBeTruthy();
|
||||
expect(screen.getByText("1 fotografia fica de fora")).toBeTruthy();
|
||||
expect(screen.getByText("solo.cr3 · 0 EV")).toBeTruthy();
|
||||
expect(api.groupRealEstate).toHaveBeenCalledOnce();
|
||||
});
|
||||
|
||||
it("lets the owner show the area from preferences", async () => {
|
||||
window.history.pushState({}, "", "/preferences");
|
||||
const api = fakeApi(me("OWNER", false));
|
||||
render(<App api={api} />);
|
||||
await userEvent.click(await screen.findByRole("button", { name: "Ligar" }));
|
||||
expect(api.setRealEstate).toHaveBeenCalledWith("o1", true);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,274 @@
|
||||
import type { BracketFrame } from "@photoreport/metadata";
|
||||
import { ApiError, hasRole, type RealEstateGrouping } from "@photoreport/sdk";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useAuth } from "../auth.js";
|
||||
import { t } from "../i18n.js";
|
||||
import { fuseBracket } from "../realestate/fuse.js";
|
||||
import { fillFromSidecar, pairKey, partitionBracketFiles, readBracketFile } from "../realestate/readFrame.js";
|
||||
import { PageHeader } from "./Shell.js";
|
||||
|
||||
const READ_AT_ONCE = 4;
|
||||
|
||||
/**
|
||||
* Interior brackets, separate from the sports library. The files stay on this computer. The server
|
||||
* only receives exposure metadata and says which frames belong to the same angle; the develop
|
||||
* engine merges each angle in the browser.
|
||||
*/
|
||||
export function RealEstatePage() {
|
||||
const { api, organization, role } = useAuth();
|
||||
const enabled = organization?.realEstateEnabled === true && role !== null && hasRole(role, "PHOTOGRAPHER");
|
||||
const [busy, setBusy] = useState(false);
|
||||
const busyRef = useRef(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [frames, setFrames] = useState<BracketFrame[]>([]);
|
||||
const [files, setFiles] = useState<Map<string, File>>(new Map());
|
||||
const [result, setResult] = useState<RealEstateGrouping | null>(null);
|
||||
const [progress, setProgress] = useState<{ done: number; total: number } | null>(null);
|
||||
const [support, setSupport] = useState(0);
|
||||
|
||||
const take = async (list: File[]) => {
|
||||
const split = partitionBracketFiles(list);
|
||||
if ((split.images.length === 0 && split.sidecars.length === 0 && split.other === 0) || busyRef.current || !organization) return;
|
||||
busyRef.current = true;
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
setResult(null);
|
||||
setFrames([]);
|
||||
setFiles(new Map());
|
||||
setSupport(split.sidecars.length + split.other);
|
||||
setProgress({ done: 0, total: split.images.length + split.sidecars.length });
|
||||
try {
|
||||
if (split.images.length === 0) {
|
||||
setError(t.realEstate.noPhotos);
|
||||
return;
|
||||
}
|
||||
let done = 0;
|
||||
const total = split.images.length + split.sidecars.length;
|
||||
const readOne = async (file: File) => {
|
||||
try {
|
||||
return await readBracketFile(file);
|
||||
} finally {
|
||||
done += 1;
|
||||
setProgress({ done, total });
|
||||
}
|
||||
};
|
||||
const read = await mapPool(split.images, READ_AT_ONCE, readOne);
|
||||
const sidecars = await mapPool(split.sidecars, READ_AT_ONCE, readOne);
|
||||
const byKey = new Map(split.sidecars.map((file, index) => [pairKey(file.webkitRelativePath || file.name), sidecars[index]!]));
|
||||
const merged = read.map((frame, index) => {
|
||||
const image = split.images[index];
|
||||
const extra = image ? byKey.get(pairKey(image.webkitRelativePath || image.name)) : undefined;
|
||||
return extra ? fillFromSidecar(frame, extra) : frame;
|
||||
});
|
||||
setFrames(merged);
|
||||
const paired = new Map<string, File>();
|
||||
merged.forEach((frame, index) => {
|
||||
const file = split.images[index];
|
||||
if (file) paired.set(frame.id, file);
|
||||
});
|
||||
setFiles(paired);
|
||||
setResult(await api.groupRealEstate(organization.id, merged));
|
||||
} catch (err) {
|
||||
const code = err instanceof ApiError ? err.code : "";
|
||||
setError(t.realEstate.errors[code] ?? t.unexpectedError);
|
||||
} finally {
|
||||
busyRef.current = false;
|
||||
setBusy(false);
|
||||
setProgress(null);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader title={t.realEstate.title} />
|
||||
<section className="max-w-3xl p-6">
|
||||
{!enabled ? (
|
||||
<p className="text-sm text-muted">{t.realEstate.disabled}</p>
|
||||
) : (
|
||||
<>
|
||||
<p className="text-sm text-muted">{t.realEstate.intro}</p>
|
||||
<p className="mt-2 text-sm text-muted">{t.realEstate.step}</p>
|
||||
<div
|
||||
className="mt-5 border border-dashed border-line bg-panel px-4 py-8 text-center"
|
||||
onDragOver={(event) => event.preventDefault()}
|
||||
onDrop={(event) => {
|
||||
event.preventDefault();
|
||||
void filesFromDrop(event.dataTransfer).then((files) => take(files));
|
||||
}}
|
||||
>
|
||||
<div className="flex flex-wrap items-center justify-center gap-3">
|
||||
<label className="inline-flex h-9 cursor-pointer items-center bg-accent px-4 font-display text-[15px] font-semibold uppercase tracking-wide text-white hover:bg-accent-strong">
|
||||
{t.realEstate.choose}
|
||||
<input
|
||||
aria-label={t.realEstate.choose}
|
||||
className="sr-only"
|
||||
type="file"
|
||||
multiple
|
||||
disabled={busy}
|
||||
onChange={(event) => {
|
||||
const list = event.target.files ? [...event.target.files] : [];
|
||||
event.target.value = "";
|
||||
void take(list);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<label className="inline-flex h-9 cursor-pointer items-center border border-line bg-panel px-4 font-display text-[15px] font-semibold uppercase tracking-wide text-ink hover:border-faint">
|
||||
{t.realEstate.chooseFolder}
|
||||
<input
|
||||
aria-label={t.realEstate.chooseFolder}
|
||||
className="sr-only"
|
||||
type="file"
|
||||
multiple
|
||||
disabled={busy}
|
||||
{...{ webkitdirectory: "", directory: "" }}
|
||||
onChange={(event) => {
|
||||
const list = event.target.files ? [...event.target.files] : [];
|
||||
event.target.value = "";
|
||||
void take(list);
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<p className="mt-3 text-[13px] text-faint">{t.realEstate.dropHint}</p>
|
||||
</div>
|
||||
{busy && progress && <p className="mt-4 text-sm text-muted">{t.realEstate.reading(progress.done, progress.total)}</p>}
|
||||
{error && <p className="mt-4 text-sm text-danger">{error}</p>}
|
||||
{support > 0 && <p className="mt-4 text-sm text-muted">{t.realEstate.support(support)}</p>}
|
||||
{result && <Grouping frames={frames} files={files} result={result} />}
|
||||
</>
|
||||
)}
|
||||
</section>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function Grouping({ frames, files, result }: { frames: BracketFrame[]; files: Map<string, File>; result: RealEstateGrouping }) {
|
||||
const byId = new Map(frames.map((frame) => [frame.id, frame]));
|
||||
return (
|
||||
<div className="mt-6 space-y-4">
|
||||
<p className="text-sm text-ink">{t.realEstate.stacks(result.stacks.length)}</p>
|
||||
{result.stacks.length === 0 && <p className="text-sm text-muted">{t.realEstate.none}</p>}
|
||||
<ul className="space-y-3">
|
||||
{result.stacks.map((stack, index) => (
|
||||
<li key={`${index}-${stack.frameIds[0] ?? ""}`} className="border border-line bg-panel">
|
||||
<p className="border-b border-line px-3 py-2 text-[13px] font-semibold">{t.realEstate.angle(index + 1, stack.frameIds.length)}</p>
|
||||
<AnglePreview index={index} ids={stack.frameIds} files={files} />
|
||||
<ul className="px-3 py-2 text-[13px] text-muted">
|
||||
{stack.frameIds.map((id) => (
|
||||
<li key={id}>{line(byId.get(id), id)}</li>
|
||||
))}
|
||||
</ul>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
{result.aside.length > 0 && (
|
||||
<div>
|
||||
<p className="text-sm text-ink">{t.realEstate.aside(result.aside.length)}</p>
|
||||
<p className="mt-1 text-[13px] text-faint">{t.realEstate.asideHelp}</p>
|
||||
<ul className="mt-2 text-[13px] text-muted">
|
||||
{result.aside.slice(0, 12).map((id) => (
|
||||
<li key={id}>{line(byId.get(id), id)}</li>
|
||||
))}
|
||||
{result.aside.length > 12 && <li>{t.realEstate.asideMore(result.aside.length - 12)}</li>}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function AnglePreview({ index, ids, files }: { index: number; ids: string[]; files: Map<string, File> }) {
|
||||
const [url, setUrl] = useState<string | null>(null);
|
||||
const [failed, setFailed] = useState(false);
|
||||
const key = ids.join("\n");
|
||||
useEffect(() => {
|
||||
const stack = ids.map((id) => files.get(id)).filter((file): file is File => file instanceof File);
|
||||
if (stack.length < 2) {
|
||||
setFailed(true);
|
||||
return;
|
||||
}
|
||||
let cancelled = false;
|
||||
let objectUrl = "";
|
||||
setUrl(null);
|
||||
setFailed(false);
|
||||
fuseBracket(stack)
|
||||
.then((blob) => {
|
||||
if (cancelled) return;
|
||||
objectUrl = URL.createObjectURL(blob);
|
||||
setUrl(objectUrl);
|
||||
})
|
||||
.catch(() => {
|
||||
if (!cancelled) setFailed(true);
|
||||
});
|
||||
return () => {
|
||||
cancelled = true;
|
||||
if (objectUrl) URL.revokeObjectURL(objectUrl);
|
||||
};
|
||||
// `key` is the stack. `files` is replaced as a whole when a new folder is read.
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [key, files]);
|
||||
if (failed) return <p className="px-3 py-2 text-[13px] text-danger">{t.realEstate.fuseFailed}</p>;
|
||||
if (!url) return <p className="px-3 py-2 text-[13px] text-muted">{t.realEstate.fusing}</p>;
|
||||
return <img alt={t.realEstate.previewAlt(index + 1)} className="block w-full" src={url} />;
|
||||
}
|
||||
|
||||
function line(frame: BracketFrame | undefined, id: string): string {
|
||||
const name = frame?.fileName || id;
|
||||
return `${name} · ${exposureLabel(frame)}`;
|
||||
}
|
||||
|
||||
function exposureLabel(frame: BracketFrame | undefined): string {
|
||||
if (!frame || (frame.exposureBias == null && (frame.exposureTime == null || frame.exposureTime <= 0))) return t.realEstate.noExposure;
|
||||
if (frame.exposureBias == null) return t.realEstate.noBias;
|
||||
return formatBias(frame.exposureBias);
|
||||
}
|
||||
|
||||
function formatBias(value: number): string {
|
||||
const rounded = Math.round(value * 10) / 10;
|
||||
const text = Number.isInteger(rounded) ? String(rounded) : rounded.toFixed(1);
|
||||
if (rounded > 0) return t.realEstate.bias(`+${text}`);
|
||||
return t.realEstate.bias(text);
|
||||
}
|
||||
|
||||
async function mapPool<T, R>(items: readonly T[], limit: number, fn: (item: T) => Promise<R>): Promise<R[]> {
|
||||
const out: R[] = new Array(items.length);
|
||||
let next = 0;
|
||||
const workers = Array.from({ length: Math.min(limit, items.length) }, async () => {
|
||||
while (next < items.length) {
|
||||
const index = next;
|
||||
next += 1;
|
||||
out[index] = await fn(items[index]!);
|
||||
}
|
||||
});
|
||||
await Promise.all(workers);
|
||||
return out;
|
||||
}
|
||||
|
||||
async function filesFromDrop(data: DataTransfer): Promise<File[]> {
|
||||
const entries: FileSystemEntry[] = [];
|
||||
for (const item of data.items) {
|
||||
const entry = item.webkitGetAsEntry?.();
|
||||
if (entry) entries.push(entry);
|
||||
}
|
||||
if (entries.length === 0) return [...data.files];
|
||||
const nested = await Promise.all(entries.map((entry) => filesInEntry(entry)));
|
||||
return nested.flat();
|
||||
}
|
||||
|
||||
async function filesInEntry(entry: FileSystemEntry): Promise<File[]> {
|
||||
if (entry.name.startsWith(".")) return [];
|
||||
if (entry.isFile) {
|
||||
const file = await new Promise<File>((resolve, reject) => (entry as FileSystemFileEntry).file(resolve, reject));
|
||||
return file.name.startsWith(".") ? [] : [file];
|
||||
}
|
||||
if (!entry.isDirectory) return [];
|
||||
const reader = (entry as FileSystemDirectoryEntry).createReader();
|
||||
const children: FileSystemEntry[] = [];
|
||||
for (;;) {
|
||||
const batch = await new Promise<FileSystemEntry[]>((resolve, reject) => reader.readEntries(resolve, reject));
|
||||
if (batch.length === 0) break;
|
||||
children.push(...batch);
|
||||
}
|
||||
const nested = await Promise.all(children.map((child) => filesInEntry(child)));
|
||||
return nested.flat();
|
||||
}
|
||||
@@ -111,6 +111,16 @@ export function Shell() {
|
||||
</NavLink>
|
||||
</>
|
||||
)}
|
||||
{organization?.realEstateEnabled === true && role !== null && hasRole(role, "PHOTOGRAPHER") && (
|
||||
<>
|
||||
<span aria-hidden="true" className="text-[#3a3a3a]">
|
||||
|
|
||||
</span>
|
||||
<NavLink to="/real-estate" className={moduleClass}>
|
||||
{t.realEstate.nav}
|
||||
</NavLink>
|
||||
</>
|
||||
)}
|
||||
</nav>
|
||||
|
||||
<Bell />
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { loadEngine } from "../develop/engine.js";
|
||||
|
||||
/** Long side of each frame. The engine bins a raw mosaic down to this instead of demosaicing it whole. */
|
||||
const PREVIEW_EDGE = 1024;
|
||||
|
||||
/**
|
||||
* Merge one angle with the develop engine (LightCraft's HDR merge) and return a JPEG preview.
|
||||
* The files stay in this browser; nothing is uploaded.
|
||||
*/
|
||||
export async function fuseBracket(files: File[]): Promise<Blob> {
|
||||
const engine = await loadEngine();
|
||||
const job = new engine.BracketJob();
|
||||
try {
|
||||
for (const file of files) {
|
||||
job.push(new Uint8Array(await file.arrayBuffer()));
|
||||
}
|
||||
const merged = job.merge(PREVIEW_EDGE);
|
||||
try {
|
||||
const jpeg = new Uint8Array(merged.jpeg());
|
||||
return new Blob([jpeg], { type: "image/jpeg" });
|
||||
} finally {
|
||||
merged.free();
|
||||
}
|
||||
} finally {
|
||||
job.free();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { bracketFileRole, fileStem, fillFromSidecar, frameFromCapture, pairKey, partitionBracketFiles, readBracketFile } from "./readFrame.js";
|
||||
|
||||
describe("frameFromCapture", () => {
|
||||
it("reads the engine's capture JSON, including a zero compensation", () => {
|
||||
const frame = frameFromCapture("id", "IMG_0001.CR3", {
|
||||
cameraMake: "Canon",
|
||||
cameraModel: "EOS R5",
|
||||
cameraSerial: "123",
|
||||
focalLength: 16,
|
||||
aperture: 8,
|
||||
iso: 100,
|
||||
width: 8192,
|
||||
height: 5464,
|
||||
exposureBias: 0,
|
||||
exposureTime: 0.01,
|
||||
capturedAt: "2026-10-21T10:00:00",
|
||||
});
|
||||
expect(frame).toMatchObject({
|
||||
id: "id",
|
||||
fileName: "IMG_0001.CR3",
|
||||
cameraMake: "Canon",
|
||||
cameraModel: "EOS R5",
|
||||
cameraSerial: "123",
|
||||
focalLength: 16,
|
||||
aperture: 8,
|
||||
iso: 100,
|
||||
width: 8192,
|
||||
height: 5464,
|
||||
exposureBias: 0,
|
||||
exposureTime: 0.01,
|
||||
capturedAt: "2026-10-21T10:00:00",
|
||||
});
|
||||
});
|
||||
|
||||
it("keeps the name when the file has no header", () => {
|
||||
expect(frameFromCapture("id", "IMG_0002.CR3", undefined)).toEqual({ id: "id", fileName: "IMG_0002.CR3" });
|
||||
});
|
||||
});
|
||||
|
||||
describe("bracket files", () => {
|
||||
it("treats an XMP next to a CR3 as a sidecar, not a photo", () => {
|
||||
expect(bracketFileRole("PSR10071.CR3")).toBe("image");
|
||||
expect(bracketFileRole("PSR10071.XMP")).toBe("sidecar");
|
||||
expect(bracketFileRole("notes.txt")).toBe("other");
|
||||
expect(fileStem("folder/PSR10071.XMP")).toBe("psr10071");
|
||||
expect(pairKey("Imovel/PSR10071.CR3")).toBe(pairKey("Imovel/PSR10071.XMP"));
|
||||
expect(pairKey("Sala/PSR10071.CR3")).not.toBe(pairKey("Quarto/PSR10071.CR3"));
|
||||
const cr3 = new File(["r"], "PSR10071.CR3");
|
||||
const xmp = new File(["x"], "PSR10071.XMP");
|
||||
const note = new File(["n"], "notes.txt");
|
||||
const split = partitionBracketFiles([cr3, xmp, note]);
|
||||
expect(split.images).toEqual([cr3]);
|
||||
expect(split.sidecars).toEqual([xmp]);
|
||||
expect(split.other).toBe(1);
|
||||
});
|
||||
|
||||
it("lets the sidecar fill an exposure the raw did not carry", () => {
|
||||
const raw = frameFromCapture("raw", "PSR10071.CR3", { cameraMake: "Canon", exposureTime: 0.01 });
|
||||
const side = frameFromCapture("side", "PSR10071.XMP", { cameraMake: "Other", exposureBias: -2, exposureTime: 0.5 });
|
||||
expect(fillFromSidecar(raw, side)).toMatchObject({ cameraMake: "Canon", exposureBias: -2, exposureTime: 0.01 });
|
||||
});
|
||||
|
||||
it("uses the reader it is given", async () => {
|
||||
const file = new File(["raw"], "PSR10071.CR3");
|
||||
const frame = await readBracketFile(file, () => JSON.stringify({ exposureBias: -2, exposureTime: 1 / 125 }));
|
||||
expect(frame.fileName).toBe("PSR10071.CR3");
|
||||
expect(frame.exposureBias).toBe(-2);
|
||||
expect(frame.exposureTime).toBeCloseTo(0.008);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,154 @@
|
||||
import type { BracketFrame } from "@photoreport/metadata";
|
||||
import { loadEngine } from "../develop/engine.js";
|
||||
|
||||
/**
|
||||
* How a dropped file participates in a bracket. Sidecars are not frames: an XMP next to a raw only
|
||||
* fills exposure the raw itself did not carry. Anything else (notes, previews) is ignored.
|
||||
*/
|
||||
export type BracketFileRole = "image" | "sidecar" | "other";
|
||||
|
||||
const IMAGE_EXTENSIONS = new Set([
|
||||
"cr2",
|
||||
"cr3",
|
||||
"crw",
|
||||
"nef",
|
||||
"nrw",
|
||||
"arw",
|
||||
"srf",
|
||||
"sr2",
|
||||
"raf",
|
||||
"orf",
|
||||
"rw2",
|
||||
"pef",
|
||||
"srw",
|
||||
"x3f",
|
||||
"3fr",
|
||||
"iiq",
|
||||
"erf",
|
||||
"kdc",
|
||||
"mrw",
|
||||
"dng",
|
||||
"raw",
|
||||
"jpg",
|
||||
"jpeg",
|
||||
"tif",
|
||||
"tiff",
|
||||
"png",
|
||||
"webp",
|
||||
"heic",
|
||||
"heif",
|
||||
]);
|
||||
|
||||
export function fileStem(name: string): string {
|
||||
const base = name.split(/[/\\]/).pop() ?? name;
|
||||
const dot = base.lastIndexOf(".");
|
||||
return (dot <= 0 ? base : base.slice(0, dot)).toLowerCase();
|
||||
}
|
||||
|
||||
/** Same folder and stem, so `Imovel/PSR10071.CR3` pairs with `Imovel/PSR10071.XMP`. */
|
||||
export function pairKey(name: string): string {
|
||||
const normalized = name.replaceAll("\\", "/");
|
||||
const slash = normalized.lastIndexOf("/");
|
||||
const dir = slash < 0 ? "" : normalized.slice(0, slash).toLowerCase();
|
||||
return `${dir}/${fileStem(normalized)}`;
|
||||
}
|
||||
|
||||
export function bracketFileRole(name: string): BracketFileRole {
|
||||
const base = name.split(/[/\\]/).pop() ?? name;
|
||||
if (base === "" || base.startsWith(".")) return "other";
|
||||
const dot = base.lastIndexOf(".");
|
||||
const ext = dot <= 0 ? "" : base.slice(dot + 1).toLowerCase();
|
||||
if (ext === "xmp") return "sidecar";
|
||||
if (IMAGE_EXTENSIONS.has(ext)) return "image";
|
||||
return "other";
|
||||
}
|
||||
|
||||
export function partitionBracketFiles(files: readonly File[]): { images: File[]; sidecars: File[]; other: number } {
|
||||
const images: File[] = [];
|
||||
const sidecars: File[] = [];
|
||||
let other = 0;
|
||||
for (const file of files) {
|
||||
const name = file.webkitRelativePath || file.name;
|
||||
const role = bracketFileRole(name);
|
||||
if (role === "image") images.push(file);
|
||||
else if (role === "sidecar") sidecars.push(file);
|
||||
else other += 1;
|
||||
}
|
||||
return { images, sidecars, other };
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills only the fields the raw left empty. The camera's own header wins over the sidecar.
|
||||
*/
|
||||
export function fillFromSidecar(frame: BracketFrame, extra: BracketFrame): BracketFrame {
|
||||
const next: BracketFrame = { ...frame };
|
||||
if (next.capturedAt == null && extra.capturedAt != null) next.capturedAt = extra.capturedAt;
|
||||
if (next.cameraSerial == null && extra.cameraSerial != null) next.cameraSerial = extra.cameraSerial;
|
||||
if (next.cameraMake == null && extra.cameraMake != null) next.cameraMake = extra.cameraMake;
|
||||
if (next.cameraModel == null && extra.cameraModel != null) next.cameraModel = extra.cameraModel;
|
||||
if (next.focalLength == null && extra.focalLength != null) next.focalLength = extra.focalLength;
|
||||
if (next.aperture == null && extra.aperture != null) next.aperture = extra.aperture;
|
||||
if (next.iso == null && extra.iso != null) next.iso = extra.iso;
|
||||
if (next.width == null && extra.width != null) next.width = extra.width;
|
||||
if (next.height == null && extra.height != null) next.height = extra.height;
|
||||
if (next.exposureBias == null && extra.exposureBias != null) next.exposureBias = extra.exposureBias;
|
||||
if (next.exposureTime == null && extra.exposureTime != null) next.exposureTime = extra.exposureTime;
|
||||
return next;
|
||||
}
|
||||
|
||||
export function frameFromCapture(id: string, fileName: string, tags: Record<string, unknown> | undefined): BracketFrame {
|
||||
const frame: BracketFrame = { id, fileName };
|
||||
if (!tags) return frame;
|
||||
const captured = text(tags.capturedAt);
|
||||
if (captured && Number.isFinite(Date.parse(captured))) frame.capturedAt = captured;
|
||||
const serial = text(tags.cameraSerial);
|
||||
if (serial) frame.cameraSerial = serial;
|
||||
const make = text(tags.cameraMake);
|
||||
if (make) frame.cameraMake = make;
|
||||
const model = text(tags.cameraModel);
|
||||
if (model) frame.cameraModel = model;
|
||||
const focal = num(tags.focalLength);
|
||||
if (focal !== null && focal > 0) frame.focalLength = focal;
|
||||
const aperture = num(tags.aperture);
|
||||
if (aperture !== null && aperture > 0) frame.aperture = aperture;
|
||||
const iso = num(tags.iso);
|
||||
if (iso !== null && iso > 0) frame.iso = Math.round(iso);
|
||||
const width = num(tags.width);
|
||||
if (width !== null && width > 0) frame.width = Math.round(width);
|
||||
const height = num(tags.height);
|
||||
if (height !== null && height > 0) frame.height = Math.round(height);
|
||||
const bias = num(tags.exposureBias);
|
||||
if (bias !== null) frame.exposureBias = bias;
|
||||
const time = num(tags.exposureTime);
|
||||
if (time !== null && time > 0) frame.exposureTime = time;
|
||||
return frame;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads capture metadata with the develop engine (LightCraft). The bytes stay in this browser.
|
||||
* A file the engine cannot read still comes back, with nothing but its name, so the grouper sets it aside.
|
||||
* `readMeta` is the engine's `readCaptureMeta`; tests pass their own.
|
||||
*/
|
||||
export async function readBracketFile(file: File, readMeta?: (bytes: Uint8Array) => string | Promise<string>): Promise<BracketFrame> {
|
||||
const name = file.webkitRelativePath || file.name;
|
||||
const id = `${name}\u0000${file.size}\u0000${file.lastModified}`;
|
||||
try {
|
||||
const bytes = new Uint8Array(await file.arrayBuffer());
|
||||
const json = readMeta ? await readMeta(bytes) : (await loadEngine()).readCaptureMeta(bytes);
|
||||
const tags = JSON.parse(json) as Record<string, unknown>;
|
||||
return frameFromCapture(id, file.name, tags);
|
||||
} catch {
|
||||
return { id, fileName: file.name };
|
||||
}
|
||||
}
|
||||
|
||||
function num(value: unknown): number | null {
|
||||
if (typeof value === "number" && Number.isFinite(value)) return value;
|
||||
return null;
|
||||
}
|
||||
|
||||
function text(value: unknown): string | null {
|
||||
if (typeof value !== "string") return null;
|
||||
const trimmed = value.trim();
|
||||
return trimmed === "" ? null : trimmed;
|
||||
}
|
||||
@@ -31,6 +31,8 @@ sha2 = "0.10"
|
||||
libc = "0.2"
|
||||
image = { version = "0.25", default-features = false, features = ["jpeg"] }
|
||||
photoreport-faces = { path = "../../../workers/faces" }
|
||||
# Capture time (EXIF / IPTC / XMP, including CR3) comes from the engine's LightCraft reader.
|
||||
photoreport-engine = { path = "../../../engine/core" }
|
||||
tauri-plugin-dialog = "2"
|
||||
tauri-plugin-updater = "2"
|
||||
# New versions of the interface (see src/ui.rs). Already built for the updater: same versions, no new crates.
|
||||
|
||||
@@ -164,14 +164,29 @@ fn sibling_jpeg(path: &Path) -> Option<PathBuf> {
|
||||
None
|
||||
}
|
||||
|
||||
/// The capture day of a photo: EXIF DateTimeOriginal when it can be read (a JPEG, or a RAW's paired JPEG), else
|
||||
/// the file's modification time — on a card straight from the camera that is when the frame was shot. RAW-only
|
||||
/// formats with no EXIF reader yet (e.g. CR3) fall back to the modification time.
|
||||
/// Year, month, day from the engine's capture clock (`YYYY-MM-DD...`), when the file recorded one.
|
||||
fn ymd_from_capture(bytes: &[u8]) -> Option<(i32, u32, u32)> {
|
||||
let value = photoreport_engine::capture::read_capture(bytes);
|
||||
let text = value.get("capturedAt")?.as_str()?;
|
||||
let year: i32 = text.get(0..4)?.parse().ok()?;
|
||||
let month: u32 = text.get(5..7)?.parse().ok()?;
|
||||
let day: u32 = text.get(8..10)?.parse().ok()?;
|
||||
if (1..=12).contains(&month) && (1..=31).contains(&day) && year > 1900 {
|
||||
Some((year, month, day))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
/// The capture day of a photo. LightCraft reads EXIF, then IPTC, then XMP, including a CR3 with no JPEG
|
||||
/// beside it. A JPEG whose header the engine cannot read still tries the short EXIF scan. Otherwise the
|
||||
/// file's modification time — on a card straight from the camera that is when the frame was shot.
|
||||
fn capture_day(path: &Path, ext: &str) -> chrono::DateTime<Local> {
|
||||
let from_engine = || std::fs::read(path).ok().and_then(|bytes| ymd_from_capture(&bytes));
|
||||
let ymd = if is_jpeg(ext) {
|
||||
crate::preview::exif_date(&read_head(path))
|
||||
} else if is_raw(ext) {
|
||||
sibling_jpeg(path).and_then(|j| crate::preview::exif_date(&read_head(&j)))
|
||||
from_engine().or_else(|| crate::preview::exif_date(&read_head(path)))
|
||||
} else if is_image(ext) {
|
||||
from_engine().or_else(|| sibling_jpeg(path).and_then(|j| crate::preview::exif_date(&read_head(&j))))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
@@ -16,6 +16,10 @@ lightcraft-codecs = { workspace = true }
|
||||
lightcraft-pipeline = { workspace = true }
|
||||
lightcraft-raster = { workspace = true }
|
||||
lightcraft-geom = { workspace = true }
|
||||
lightcraft-merge = { workspace = true }
|
||||
lightcraft-raw = { workspace = true }
|
||||
lightcraft-color = { workspace = true }
|
||||
lightcraft-meta = { workspace = true }
|
||||
serde = { workspace = true }
|
||||
serde_json = { workspace = true }
|
||||
thiserror = { workspace = true }
|
||||
@@ -0,0 +1,163 @@
|
||||
//! Capture metadata for one photo, read by LightCraft (`lightcraft-meta`).
|
||||
//!
|
||||
//! EXIF first, then IPTC fills whatever is still empty, then XMP overrides the user fields and fills the
|
||||
//! rest. That covers JPEG, PNG, WebP, TIFF, DNG and the raws LightCraft opens, including Canon CR3.
|
||||
//! A loose XMP sidecar (the XML file next to a raw) is read the same way.
|
||||
|
||||
use lightcraft_meta::Metadata;
|
||||
use serde::Serialize;
|
||||
use serde_json::{Value, json};
|
||||
|
||||
#[derive(Serialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
struct Capture {
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
camera_make: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
camera_model: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
camera_serial: Option<String>,
|
||||
/// ISO 8601. The offset is included when the file recorded one.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
captured_at: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
focal_length: Option<f64>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
aperture: Option<f64>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
iso: Option<u32>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
width: Option<u32>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
height: Option<u32>,
|
||||
/// EV. Zero is a real compensation and is kept.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
exposure_bias: Option<f64>,
|
||||
/// Seconds.
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
exposure_time: Option<f64>,
|
||||
}
|
||||
|
||||
fn positive(value: Option<f64>) -> Option<f64> {
|
||||
value.filter(|n| n.is_finite() && *n > 0.0)
|
||||
}
|
||||
|
||||
fn finite(value: Option<f64>) -> Option<f64> {
|
||||
value.filter(|n| n.is_finite())
|
||||
}
|
||||
|
||||
fn text(value: Option<String>) -> Option<String> {
|
||||
value
|
||||
.map(|s| s.trim().trim_end_matches('\0').to_string())
|
||||
.filter(|s| !s.is_empty())
|
||||
}
|
||||
|
||||
fn from_meta(meta: &Metadata) -> Capture {
|
||||
Capture {
|
||||
camera_make: text(meta.make.clone()),
|
||||
camera_model: text(meta.model.clone()),
|
||||
camera_serial: text(meta.serial_number.clone()),
|
||||
captured_at: meta
|
||||
.capture_time
|
||||
.filter(|t| t.year > 1900)
|
||||
.map(|t| t.to_iso()),
|
||||
focal_length: positive(meta.focal_length),
|
||||
aperture: positive(meta.f_number),
|
||||
iso: meta.iso.filter(|n| *n > 0),
|
||||
width: meta.width.filter(|n| *n > 0),
|
||||
height: meta.height.filter(|n| *n > 0),
|
||||
exposure_bias: finite(meta.exposure_bias),
|
||||
exposure_time: positive(meta.exposure_time),
|
||||
}
|
||||
}
|
||||
|
||||
fn present(capture: &Capture) -> bool {
|
||||
capture.camera_make.is_some()
|
||||
|| capture.camera_model.is_some()
|
||||
|| capture.camera_serial.is_some()
|
||||
|| capture.captured_at.is_some()
|
||||
|| capture.focal_length.is_some()
|
||||
|| capture.aperture.is_some()
|
||||
|| capture.iso.is_some()
|
||||
|| capture.width.is_some()
|
||||
|| capture.height.is_some()
|
||||
|| capture.exposure_bias.is_some()
|
||||
|| capture.exposure_time.is_some()
|
||||
}
|
||||
|
||||
fn value_of(capture: &Capture) -> Value {
|
||||
serde_json::to_value(capture).unwrap_or_else(|_| json!({}))
|
||||
}
|
||||
|
||||
/// Capture fields as a JSON object. A file with none of them yields `{}`.
|
||||
pub fn read_capture(bytes: &[u8]) -> Value {
|
||||
let from_file = from_meta(&lightcraft_meta::extract(bytes));
|
||||
if present(&from_file) {
|
||||
return value_of(&from_file);
|
||||
}
|
||||
// A sidecar is not a container. `extract` finds nothing; the packet itself is the metadata.
|
||||
if let Ok(text) = std::str::from_utf8(bytes) {
|
||||
let trimmed = text.trim_start_matches('\u{feff}').trim_start();
|
||||
if trimmed.starts_with('<')
|
||||
&& let Ok(xmp) = lightcraft_meta::parse_xmp(trimmed)
|
||||
{
|
||||
let from_xmp = from_meta(&xmp.metadata);
|
||||
if present(&from_xmp) {
|
||||
return value_of(&from_xmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
value_of(&from_file)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use lightcraft_meta::{DateTime, Metadata, write_exif, write_xmp};
|
||||
|
||||
fn sample() -> Metadata {
|
||||
Metadata {
|
||||
make: Some("Canon".into()),
|
||||
model: Some("EOS R5".into()),
|
||||
serial_number: Some("123".into()),
|
||||
capture_time: DateTime::parse_iso("2026-10-21T10:00:00"),
|
||||
focal_length: Some(16.0),
|
||||
f_number: Some(8.0),
|
||||
iso: Some(100),
|
||||
exposure_bias: Some(-2.0),
|
||||
exposure_time: Some(0.01),
|
||||
..Metadata::default()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn exif_block_round_trips_the_bracket_fields() {
|
||||
let meta = sample();
|
||||
let json = read_capture(&write_exif(&meta));
|
||||
assert_eq!(json["cameraMake"], "Canon");
|
||||
assert_eq!(json["cameraModel"], "EOS R5");
|
||||
assert_eq!(json["capturedAt"], meta.capture_time.unwrap().to_iso());
|
||||
assert_eq!(json["focalLength"], 16.0);
|
||||
assert_eq!(json["aperture"], 8.0);
|
||||
assert_eq!(json["iso"], 100);
|
||||
assert_eq!(json["exposureBias"], -2.0);
|
||||
let shutter = json["exposureTime"].as_f64().unwrap();
|
||||
assert!((shutter - 0.01).abs() < 1e-6, "{shutter}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn xmp_sidecar_round_trips_the_bracket_fields() {
|
||||
let meta = sample();
|
||||
let json = read_capture(write_xmp(&meta, None).as_bytes());
|
||||
assert_eq!(json["cameraMake"], "Canon");
|
||||
assert_eq!(json["exposureBias"], -2.0);
|
||||
assert_eq!(json["capturedAt"], meta.capture_time.unwrap().to_iso());
|
||||
let shutter = json["exposureTime"].as_f64().unwrap();
|
||||
assert!((shutter - 0.01).abs() < 1e-6, "{shutter}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unknown_bytes_are_empty() {
|
||||
assert_eq!(read_capture(b"not a photo"), json!({}));
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,9 @@
|
||||
//! small JSON edit commands addressed by LightCraft control ids (`light.exposure`, `effects.clarity`, ...).
|
||||
//! Updating LightCraft should only ever require changes in this crate.
|
||||
|
||||
pub mod capture;
|
||||
pub mod level;
|
||||
pub mod merge;
|
||||
pub mod render;
|
||||
|
||||
pub use lightcraft_develop::DevelopSettings;
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
//! Exposure brackets through LightCraft's HDR merge (`lightcraft-merge`).
|
||||
//!
|
||||
//! This is not the `hdr.*` develop panel. That panel is display headroom for one photo. Here several
|
||||
//! exposures of the same angle become one scene-linear image: the engine aligns them, measures the
|
||||
//! exposure steps, and weights each pixel so a clipped channel contributes nothing. The result is
|
||||
//! developed with the engine's Auto settings (the same finish LightCraft applies to a merge).
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
use lightcraft_color::Xy;
|
||||
use lightcraft_develop::DevelopSettings;
|
||||
use lightcraft_merge::frame::Frame;
|
||||
use lightcraft_merge::{Deghost, FrameColor, HdrOptions, HdrResult, merge_hdr, no_progress};
|
||||
use lightcraft_pipeline::{Quality, RenderRequest, SourceInfo, auto};
|
||||
use lightcraft_raster::Rgb32f;
|
||||
use lightcraft_raster::resample::{Filter, fit};
|
||||
use lightcraft_raw::ColorData;
|
||||
|
||||
use crate::EngineError;
|
||||
use crate::render::Pixels;
|
||||
|
||||
/// Longest edge of a preview. A full-sensor demosaic does not belong in this path.
|
||||
const EDGE_CAP: u32 = 4096;
|
||||
|
||||
/// Merge `files` (raw or a standard image the engine reads) into one developed preview.
|
||||
/// `max_edge` is the long side of each frame before the merge, clamped to 64..=4096.
|
||||
pub fn merge_brackets(files: &[&[u8]], max_edge: u32) -> Result<Pixels, EngineError> {
|
||||
let (image, info) = fuse_working(files, max_edge)?;
|
||||
let edge = clamped_edge(max_edge);
|
||||
let mut settings = if info.raw {
|
||||
DevelopSettings::for_raw(info.as_shot_temp, info.as_shot_tint)
|
||||
} else {
|
||||
DevelopSettings::default()
|
||||
};
|
||||
let tone = auto::auto_tone(&image, &info, &settings);
|
||||
settings.light.exposure = tone.exposure;
|
||||
settings.light.contrast = tone.contrast;
|
||||
settings.light.highlights = tone.highlights;
|
||||
settings.light.shadows = tone.shadows;
|
||||
settings.light.whites = tone.whites;
|
||||
settings.light.blacks = tone.blacks;
|
||||
settings.color.vibrance = tone.vibrance;
|
||||
settings.color.saturation = tone.saturation;
|
||||
let req = RenderRequest {
|
||||
quality: Quality::Full,
|
||||
apply_crop: false,
|
||||
..RenderRequest::fit(edge, edge)
|
||||
};
|
||||
let out = lightcraft_pipeline::render(&image, &info, &settings, &req);
|
||||
let (width, height) = (out.image.width as u32, out.image.height as u32);
|
||||
let rgba = out.image.data.iter().flat_map(|p| *p).collect();
|
||||
Ok(Pixels {
|
||||
width,
|
||||
height,
|
||||
rgba,
|
||||
})
|
||||
}
|
||||
|
||||
/// Scene-linear working image of a merge, before the develop finish. Tests check that a clipped
|
||||
/// window and a black interior both survive this step.
|
||||
pub(crate) fn fuse_working(
|
||||
files: &[&[u8]],
|
||||
max_edge: u32,
|
||||
) -> Result<(Rgb32f, SourceInfo), EngineError> {
|
||||
if files.len() < 2 {
|
||||
return Err(EngineError::Decode(
|
||||
"a bracket needs at least two exposures".into(),
|
||||
));
|
||||
}
|
||||
let edge = clamped_edge(max_edge);
|
||||
let mut frames = Vec::with_capacity(files.len());
|
||||
for bytes in files {
|
||||
frames.push(load_bracket_frame(bytes, edge)?);
|
||||
}
|
||||
let merged = merge_hdr(
|
||||
frames,
|
||||
&HdrOptions {
|
||||
align: true,
|
||||
deghost: Deghost::None,
|
||||
},
|
||||
&no_progress,
|
||||
)
|
||||
.map_err(|e| EngineError::Decode(e.to_string()))?;
|
||||
Ok(to_working(&merged))
|
||||
}
|
||||
|
||||
fn clamped_edge(max_edge: u32) -> usize {
|
||||
max_edge.clamp(64, EDGE_CAP) as usize
|
||||
}
|
||||
|
||||
/// A frame no larger than `max_edge`. Raw mosaics are binned instead of demosaiced at full size.
|
||||
fn load_bracket_frame(bytes: &[u8], max_edge: usize) -> Result<Frame, EngineError> {
|
||||
if lightcraft_raw::probe(bytes).is_none() {
|
||||
return lightcraft_merge::load_frame(bytes, Some(max_edge), false)
|
||||
.map_err(|e| EngineError::Decode(e.to_string()));
|
||||
}
|
||||
let mut raw = lightcraft_raw::decode(bytes).map_err(|e| EngineError::Decode(e.to_string()))?;
|
||||
// Merged uncorrected. The reference frame's corrections travel with the frame, as the engine does,
|
||||
// so a later full-size file can apply them once.
|
||||
let (aw, ah) = (raw.active_area.width, raw.active_area.height);
|
||||
let crop = raw.develop_crop(aw, ah);
|
||||
let lens = lightcraft_raw::opcodes::applied_ops(&raw.opcodes.list3)
|
||||
.filter(|op| op.is_lens_correction())
|
||||
.filter_map(|op| op.cropped(aw, ah, crop))
|
||||
.map(|op| match op {
|
||||
lightcraft_raw::Opcode::WarpRectilinear2 {
|
||||
planes,
|
||||
center,
|
||||
reciprocal,
|
||||
..
|
||||
} => lightcraft_raw::Opcode::WarpRectilinear2 {
|
||||
planes,
|
||||
center,
|
||||
reciprocal,
|
||||
optional: false,
|
||||
},
|
||||
op => op,
|
||||
})
|
||||
.collect();
|
||||
raw.opcodes.list3.retain(|op| !op.is_lens_correction());
|
||||
let long = raw.active_area.width.max(raw.active_area.height);
|
||||
let mut image = if let Some(k) = bin_factor(&raw, max_edge) {
|
||||
raw.develop_binned(k, 0.99)
|
||||
.map_err(|e| EngineError::Decode(e.to_string()))?
|
||||
.ok_or_else(|| EngineError::Decode("this raw cannot be reduced for a preview".into()))?
|
||||
} else if long <= max_edge.saturating_mul(2) {
|
||||
raw.develop(lightcraft_raw::Method::Bilinear)
|
||||
.map_err(|e| EngineError::Decode(e.to_string()))?
|
||||
} else {
|
||||
return Err(EngineError::Decode(
|
||||
"this raw cannot be reduced for a preview".into(),
|
||||
));
|
||||
};
|
||||
for p in image.data.iter_mut() {
|
||||
*p = p.map(|v| v.max(0.0));
|
||||
}
|
||||
if image.width.max(image.height) > max_edge {
|
||||
image = fit(&image, max_edge, max_edge, Filter::Box);
|
||||
}
|
||||
let metadata = if raw.metadata == lightcraft_meta::Metadata::default() {
|
||||
lightcraft_meta::extract(bytes)
|
||||
} else {
|
||||
raw.metadata.clone()
|
||||
};
|
||||
let mut exposure = lightcraft_merge::frame::exif_exposure(&metadata);
|
||||
if exposure.is_none() {
|
||||
exposure = lightcraft_merge::frame::exif_exposure(&raw.metadata);
|
||||
}
|
||||
Ok(Frame {
|
||||
clip: lightcraft_merge::frame::detect_clip(&image),
|
||||
image,
|
||||
exposure,
|
||||
raw: true,
|
||||
color: FrameColor::Camera(Box::new(raw.color.clone())),
|
||||
orientation: raw.orientation,
|
||||
metadata,
|
||||
baseline_exposure: raw.color.baseline_exposure,
|
||||
lens,
|
||||
wb_multipliers: raw.wb_multipliers,
|
||||
})
|
||||
}
|
||||
|
||||
fn bin_factor(raw: &lightcraft_raw::RawImage, max_edge: usize) -> Option<usize> {
|
||||
let long = raw.active_area.width.max(raw.active_area.height);
|
||||
let need = max_edge.max(1);
|
||||
[8usize, 6, 4, 3, 2]
|
||||
.into_iter()
|
||||
.find(|&k| raw.can_bin(k) && long / k >= need)
|
||||
}
|
||||
|
||||
fn to_working(merged: &HdrResult) -> (Rgb32f, SourceInfo) {
|
||||
let image = merged.radiance.clone().into_oriented(merged.orientation);
|
||||
let gain = 2f32.powf(merged.baseline_exposure as f32);
|
||||
match &merged.color {
|
||||
FrameColor::Camera(color) => camera_working(image, color, gain),
|
||||
FrameColor::Linear { to_xyz_d50 } => {
|
||||
let to_rec = lightcraft_color::REC2020
|
||||
.from_xyz()
|
||||
.mul(&lightcraft_color::bradford(
|
||||
lightcraft_color::D50,
|
||||
lightcraft_color::D65,
|
||||
))
|
||||
.mul(to_xyz_d50);
|
||||
let m = to_rec.to_f32();
|
||||
let image = image.map(|p| apply_mat(&m, p).map(|v| v.max(0.0) * gain));
|
||||
(image, SourceInfo::default())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn camera_working(image: Rgb32f, color: &ColorData, gain: f32) -> (Rgb32f, SourceInfo) {
|
||||
let white = as_shot_xy(color);
|
||||
let transform = lightcraft_raw::color::camera_transform_of(color, white);
|
||||
let m = transform.matrix.to_f32();
|
||||
let wb = transform.wb;
|
||||
let image = image.map(|p| {
|
||||
let balanced = [p[0] * wb[0], p[1] * wb[1], p[2] * wb[2]];
|
||||
apply_mat(&m, balanced).map(|v| v.max(0.0) * gain)
|
||||
});
|
||||
let (temp, tint) = lightcraft_color::cct::xy_to_temp_tint(white);
|
||||
let info = SourceInfo {
|
||||
raw: true,
|
||||
as_shot_temp: temp,
|
||||
as_shot_tint: tint,
|
||||
camera_color: Some(Arc::new(lightcraft_pipeline::CameraColor {
|
||||
tags: color.clone(),
|
||||
developed_for: white,
|
||||
})),
|
||||
..SourceInfo::default()
|
||||
};
|
||||
(image, info)
|
||||
}
|
||||
|
||||
fn as_shot_xy(color: &ColorData) -> Xy {
|
||||
if let Some(xy) = color.as_shot_white_xy {
|
||||
return xy;
|
||||
}
|
||||
if let Some(neutral) = color.as_shot_neutral {
|
||||
return lightcraft_raw::color::neutral_to_xy(color, neutral);
|
||||
}
|
||||
lightcraft_color::D65
|
||||
}
|
||||
|
||||
fn apply_mat(m: &[[f32; 3]; 3], p: [f32; 3]) -> [f32; 3] {
|
||||
[
|
||||
m[0][0] * p[0] + m[0][1] * p[1] + m[0][2] * p[2],
|
||||
m[1][0] * p[0] + m[1][1] * p[1] + m[1][2] * p[2],
|
||||
m[2][0] * p[0] + m[2][1] * p[1] + m[2][2] * p[2],
|
||||
]
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use lightcraft_geom::Orientation;
|
||||
use lightcraft_merge::{DngSamples, write_linear_dng};
|
||||
use lightcraft_meta::Metadata;
|
||||
|
||||
fn linear_color() -> FrameColor {
|
||||
FrameColor::Linear {
|
||||
to_xyz_d50: lightcraft_color::bradford(lightcraft_color::D65, lightcraft_color::D50)
|
||||
.mul(&lightcraft_color::SRGB.to_xyz()),
|
||||
}
|
||||
}
|
||||
|
||||
/// Left half is a window (bright), right half is the room (dark), with a stable texture so
|
||||
/// alignment has something to lock onto. `ev` is relative to the middle exposure.
|
||||
fn exposure_dng(ev: f64) -> Vec<u8> {
|
||||
let (w, h) = (320usize, 240usize);
|
||||
let k = 2f32.powf(ev as f32);
|
||||
let img = Rgb32f::from_fn(w, h, |x, y| {
|
||||
let window = x < w / 2;
|
||||
let base = if window { 2.0 } else { 0.04 };
|
||||
let grain = ((x * 13 + y * 7) % 5) as f32 / 20.0 + 0.9;
|
||||
[base * grain * k; 3].map(|v| v.clamp(0.0, 1.0))
|
||||
});
|
||||
let meta = Metadata {
|
||||
exposure_time: Some(2f64.powf(ev) / 60.0),
|
||||
f_number: Some(8.0),
|
||||
iso: Some(100),
|
||||
..Metadata::default()
|
||||
};
|
||||
write_linear_dng(
|
||||
&img,
|
||||
&linear_color(),
|
||||
Orientation::Normal,
|
||||
&meta,
|
||||
0.0,
|
||||
DngSamples::U16,
|
||||
&[],
|
||||
)
|
||||
.expect("dng")
|
||||
}
|
||||
|
||||
fn mean_green(img: &Rgb32f, x0: usize, x1: usize) -> f32 {
|
||||
let mut sum = 0f64;
|
||||
let mut n = 0usize;
|
||||
let y0 = 16;
|
||||
let y1 = img.height.saturating_sub(16);
|
||||
for y in y0..y1 {
|
||||
for x in x0..x1 {
|
||||
sum += img.get(x, y)[1] as f64;
|
||||
n += 1;
|
||||
}
|
||||
}
|
||||
(sum / n.max(1) as f64) as f32
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn window_and_interior_both_survive() {
|
||||
let dark = exposure_dng(-2.0);
|
||||
let mid = exposure_dng(0.0);
|
||||
let bright = exposure_dng(2.0);
|
||||
let files = [dark.as_slice(), mid.as_slice(), bright.as_slice()];
|
||||
let (image, _) = fuse_working(&files, 512).expect("merge");
|
||||
let mid_x = image.width / 2;
|
||||
let window = mean_green(&image, 16, mid_x.saturating_sub(16));
|
||||
let room = mean_green(&image, mid_x + 16, image.width.saturating_sub(16));
|
||||
// The bright frame clipped the window at 1. The dark frame still held it, so the merge
|
||||
// comes back above that clip. The room was black in the dark frame and readable in the bright one.
|
||||
assert!(
|
||||
window > 1.2,
|
||||
"window should be recovered past the clip, got {window}"
|
||||
);
|
||||
assert!(
|
||||
room > 0.02 && room < 0.5,
|
||||
"room should be open but not blown, got {room}"
|
||||
);
|
||||
let preview = merge_brackets(&files, 512).expect("preview");
|
||||
assert!(preview.width > 0 && preview.height > 0);
|
||||
assert_eq!(
|
||||
preview.rgba.len(),
|
||||
preview.width as usize * preview.height as usize * 4
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn one_photo_is_not_a_bracket() {
|
||||
let mid = exposure_dng(0.0);
|
||||
match merge_brackets(&[mid.as_slice()], 256) {
|
||||
Err(EngineError::Decode(_)) => {}
|
||||
Err(err) => panic!("unexpected error: {err}"),
|
||||
Ok(_) => panic!("one photo was merged"),
|
||||
}
|
||||
}
|
||||
}
|
||||
+66
-1
@@ -2,7 +2,7 @@
|
||||
//! slider move, and gets RGBA pixels back. Settings and commands cross the boundary as JSON strings, the
|
||||
//! same documents the API stores, so there is one format everywhere.
|
||||
|
||||
use photoreport_engine::render::Source;
|
||||
use photoreport_engine::render::{Source, encode_jpeg};
|
||||
use photoreport_engine::{DevelopSettings, EditCommand};
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
@@ -18,6 +18,13 @@ fn settings_from(json: &str) -> Result<DevelopSettings, JsError> {
|
||||
DevelopSettings::from_json(&v).map_err(js_err)
|
||||
}
|
||||
|
||||
/// Capture metadata (camera, clock, exposure) as JSON. LightCraft reads EXIF, then IPTC, then XMP,
|
||||
/// including Canon CR3 and a loose XMP sidecar. A file with none of those fields yields `{}`.
|
||||
#[wasm_bindgen(js_name = readCaptureMeta)]
|
||||
pub fn read_capture_meta(bytes: &[u8]) -> String {
|
||||
photoreport_engine::capture::read_capture(bytes).to_string()
|
||||
}
|
||||
|
||||
/// Every develop control of the pinned LightCraft version (id, module, label, range, default, step).
|
||||
#[wasm_bindgen]
|
||||
pub fn controls() -> Result<String, JsError> {
|
||||
@@ -163,6 +170,64 @@ impl Photo {
|
||||
}
|
||||
}
|
||||
|
||||
/// Exposures of one angle, held until [`BracketJob::merge`].
|
||||
#[wasm_bindgen]
|
||||
#[derive(Default)]
|
||||
pub struct BracketJob {
|
||||
files: Vec<Vec<u8>>,
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl BracketJob {
|
||||
#[wasm_bindgen(constructor)]
|
||||
pub fn new() -> BracketJob {
|
||||
BracketJob::default()
|
||||
}
|
||||
|
||||
/// One photo's bytes. The order is the order they are merged.
|
||||
pub fn push(&mut self, bytes: &[u8]) {
|
||||
self.files.push(bytes.to_vec());
|
||||
}
|
||||
|
||||
/// Developed JPEG preview of the merged bracket. `max_edge` is the long side of each frame.
|
||||
pub fn merge(&self, max_edge: u32) -> Result<BracketMerge, JsError> {
|
||||
let refs: Vec<&[u8]> = self.files.iter().map(Vec::as_slice).collect();
|
||||
let pixels = photoreport_engine::merge::merge_brackets(&refs, max_edge).map_err(js_err)?;
|
||||
let jpeg = encode_jpeg(&pixels, 90).map_err(js_err)?;
|
||||
Ok(BracketMerge {
|
||||
width: pixels.width,
|
||||
height: pixels.height,
|
||||
jpeg,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// A merged bracket, as a baseline JPEG.
|
||||
#[wasm_bindgen]
|
||||
pub struct BracketMerge {
|
||||
width: u32,
|
||||
height: u32,
|
||||
jpeg: Vec<u8>,
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
impl BracketMerge {
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn width(&self) -> u32 {
|
||||
self.width
|
||||
}
|
||||
|
||||
#[wasm_bindgen(getter)]
|
||||
pub fn height(&self) -> u32 {
|
||||
self.height
|
||||
}
|
||||
|
||||
/// JPEG bytes (copied out to JS).
|
||||
pub fn jpeg(&self) -> Vec<u8> {
|
||||
self.jpeg.clone()
|
||||
}
|
||||
}
|
||||
|
||||
fn values_json(values: Vec<(&'static str, f64)>) -> Result<String, JsError> {
|
||||
let map: serde_json::Map<String, serde_json::Value> = values
|
||||
.into_iter()
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { groupBrackets, type BracketFrame } from "./brackets.js";
|
||||
|
||||
const START = Date.parse("2026-10-21T10:00:00.000Z");
|
||||
|
||||
function frame(id: string, bias: number, atMs: number, extra: Partial<BracketFrame> = {}): BracketFrame {
|
||||
return {
|
||||
id,
|
||||
fileName: `${id}.CR3`,
|
||||
capturedAt: new Date(START + atMs).toISOString(),
|
||||
cameraSerial: "body",
|
||||
focalLength: 16,
|
||||
aperture: 8,
|
||||
iso: 100,
|
||||
width: 6000,
|
||||
height: 4000,
|
||||
exposureBias: bias,
|
||||
exposureTime: 1 / 100,
|
||||
...extra,
|
||||
};
|
||||
}
|
||||
|
||||
function stackIds(frames: BracketFrame[]): string[][] {
|
||||
return groupBrackets(frames).stacks.map((stack) => stack.frameIds);
|
||||
}
|
||||
|
||||
describe("real-estate brackets", () => {
|
||||
it("keeps a three-frame ±2 bracket as one angle", () => {
|
||||
const frames = [frame("dark", -2, 0), frame("mid", 0, 200), frame("bright", 2, 400)];
|
||||
expect(stackIds(frames)).toEqual([["dark", "mid", "bright"]]);
|
||||
expect(groupBrackets(frames).aside).toEqual([]);
|
||||
});
|
||||
|
||||
it("keeps a five-frame bracket together", () => {
|
||||
const frames = [-2, -1, 0, 1, 2].map((bias, index) => frame(`f${index}`, bias, index * 200));
|
||||
expect(stackIds(frames)).toEqual([["f0", "f1", "f2", "f3", "f4"]]);
|
||||
});
|
||||
|
||||
it("splits two angles shot a second apart when the compensation repeats", () => {
|
||||
const first = [frame("a", -2, 0), frame("b", 0, 200), frame("c", 2, 400)];
|
||||
const second = [frame("d", -2, 600), frame("e", 0, 800), frame("f", 2, 1000)];
|
||||
expect(stackIds([...first, ...second])).toEqual([
|
||||
["a", "b", "c"],
|
||||
["d", "e", "f"],
|
||||
]);
|
||||
});
|
||||
|
||||
it("leaves a loose frame between two angles out of both stacks", () => {
|
||||
const frames = [
|
||||
frame("a", -2, 0),
|
||||
frame("b", 0, 200),
|
||||
frame("c", 2, 400),
|
||||
frame("solo", 0, 30_000),
|
||||
frame("d", -2, 60_000),
|
||||
frame("e", 0, 60_200),
|
||||
frame("f", 2, 60_400),
|
||||
];
|
||||
const grouped = groupBrackets(frames);
|
||||
expect(grouped.stacks.map((stack) => stack.frameIds)).toEqual([
|
||||
["a", "b", "c"],
|
||||
["d", "e", "f"],
|
||||
]);
|
||||
expect(grouped.aside).toEqual(["solo"]);
|
||||
});
|
||||
|
||||
it("counts a long exposure from when the shutter closes, not from when it opens", () => {
|
||||
const frames = [
|
||||
frame("dark", -2, 0, { exposureTime: 20 }),
|
||||
frame("mid", 0, 20_000, { exposureTime: 5 }),
|
||||
frame("bright", 2, 25_000, { exposureTime: 1 }),
|
||||
];
|
||||
expect(stackIds(frames)).toEqual([["dark", "mid", "bright"]]);
|
||||
});
|
||||
|
||||
it("groups a manual bracket whose compensation stays at zero and whose shutter changes", () => {
|
||||
const frames = [
|
||||
frame("dark", 0, 0, { exposureTime: 1 / 30 }),
|
||||
frame("mid", 0, 200, { exposureTime: 1 / 8 }),
|
||||
frame("bright", 0, 400, { exposureTime: 1 / 2 }),
|
||||
];
|
||||
expect(stackIds(frames)).toEqual([["dark", "mid", "bright"]]);
|
||||
});
|
||||
|
||||
it("does not stack a same-exposure burst", () => {
|
||||
const frames = Array.from({ length: 8 }, (_, index) => frame(`b${index}`, 0, index * 50, { exposureTime: 1 / 500 }));
|
||||
const grouped = groupBrackets(frames);
|
||||
expect(grouped.stacks).toEqual([]);
|
||||
expect(grouped.aside).toEqual(frames.map((item) => item.id));
|
||||
});
|
||||
|
||||
it("leaves a two-frame pair and a bracket that barely changes exposure aside", () => {
|
||||
const pair = [frame("p0", -2, 0), frame("p1", 2, 200)];
|
||||
const nudge = [frame("n0", 0, 10_000), frame("n1", 0.3, 10_200), frame("n2", 0.7, 10_400)];
|
||||
const grouped = groupBrackets([...pair, ...nudge]);
|
||||
expect(grouped.stacks).toEqual([]);
|
||||
expect(grouped.aside).toEqual(["p0", "p1", "n0", "n1", "n2"]);
|
||||
});
|
||||
|
||||
it("does not mix two focal lengths or two bodies", () => {
|
||||
const wide = [frame("w0", -2, 0), frame("w1", 0, 200), frame("w2", 2, 400, { focalLength: 35 })];
|
||||
expect(stackIds(wide)).toEqual([]);
|
||||
const mixed = [
|
||||
frame("a0", -2, 0, { cameraSerial: "A" }),
|
||||
frame("b0", -2, 100, { cameraSerial: "B" }),
|
||||
frame("a1", 0, 200, { cameraSerial: "A" }),
|
||||
frame("b1", 0, 300, { cameraSerial: "B" }),
|
||||
frame("a2", 2, 400, { cameraSerial: "A" }),
|
||||
frame("b2", 2, 500, { cameraSerial: "B" }),
|
||||
];
|
||||
expect(stackIds(mixed)).toEqual([]);
|
||||
expect(groupBrackets(mixed).aside).toHaveLength(6);
|
||||
});
|
||||
|
||||
it("orders a bracket by the file name when the clock is missing", () => {
|
||||
const frames = [
|
||||
frame("IMG_10", 2, 0, { capturedAt: null, fileName: "IMG_10.CR3" }),
|
||||
frame("IMG_2", 0, 0, { capturedAt: null, fileName: "IMG_2.CR3" }),
|
||||
frame("IMG_1", -2, 0, { capturedAt: null, fileName: "IMG_1.CR3" }),
|
||||
];
|
||||
expect(stackIds(frames)).toEqual([["IMG_1", "IMG_2", "IMG_10"]]);
|
||||
});
|
||||
|
||||
it("returns nothing for an empty folder", () => {
|
||||
expect(groupBrackets([])).toEqual({ stacks: [], aside: [] });
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,194 @@
|
||||
/**
|
||||
* Groups a real-estate shoot into one stack per camera angle.
|
||||
*
|
||||
* Cameras do not agree on a "this is a bracket" tag. The portable signal is the exposure
|
||||
* compensation (EXIF ExposureBiasValue), together with the same body, lens, aperture, ISO
|
||||
* and frame size. A repeated compensation starts the next angle, so two brackets fired a
|
||||
* second apart stay apart. Time is only the gap after the shutter closes: a long exposure
|
||||
* is still one angle, and a frame shot after the photographer has moved is not.
|
||||
*/
|
||||
|
||||
/** Quiet time after one exposure ends before the next frame is another angle. */
|
||||
const GAP_AFTER_EXPOSURE_SECONDS = 4;
|
||||
/** Two frames are not the bracket this area merges. */
|
||||
const MIN_STACK_FRAMES = 3;
|
||||
/** Darkest to brightest. ±1 EV around the middle is 2; a nudge of a third of a stop is not. */
|
||||
const MIN_SPAN_STOPS = 1.5;
|
||||
|
||||
export interface BracketFrame {
|
||||
id: string;
|
||||
fileName?: string | null;
|
||||
/** ISO-8601. Only differences matter, so a shared wall clock is enough. */
|
||||
capturedAt?: string | null;
|
||||
cameraSerial?: string | null;
|
||||
cameraMake?: string | null;
|
||||
cameraModel?: string | null;
|
||||
focalLength?: number | null;
|
||||
aperture?: number | null;
|
||||
iso?: number | null;
|
||||
width?: number | null;
|
||||
height?: number | null;
|
||||
/** EV. Null when the body left it out and only the shutter changed. */
|
||||
exposureBias?: number | null;
|
||||
/** Seconds. */
|
||||
exposureTime?: number | null;
|
||||
}
|
||||
|
||||
export interface BracketGrouping {
|
||||
/** Capture order inside each stack. */
|
||||
stacks: { frameIds: string[] }[];
|
||||
/** Frames that are not part of a stack, in capture order. */
|
||||
aside: string[];
|
||||
}
|
||||
|
||||
export function groupBrackets(frames: readonly BracketFrame[]): BracketGrouping {
|
||||
const sorted = [...frames].sort(byCapture);
|
||||
const stacked = new Set<BracketFrame>();
|
||||
const stacks: { frameIds: string[] }[] = [];
|
||||
for (const run of runsOf(sorted)) {
|
||||
for (const group of splitByExposure(run)) {
|
||||
if (!isStack(group)) continue;
|
||||
stacks.push({ frameIds: group.map((frame) => frame.id) });
|
||||
for (const frame of group) stacked.add(frame);
|
||||
}
|
||||
}
|
||||
return { stacks, aside: sorted.filter((frame) => !stacked.has(frame)).map((frame) => frame.id) };
|
||||
}
|
||||
|
||||
function runsOf(sorted: readonly BracketFrame[]): BracketFrame[][] {
|
||||
const runs: BracketFrame[][] = [];
|
||||
let current: BracketFrame[] = [];
|
||||
for (const frame of sorted) {
|
||||
const first = current[0];
|
||||
const prev = current[current.length - 1];
|
||||
if (!first || !prev || !sameAngle(first, frame) || gapTooWide(prev, frame)) {
|
||||
if (current.length > 0) runs.push(current);
|
||||
current = [];
|
||||
}
|
||||
current.push(frame);
|
||||
}
|
||||
if (current.length > 0) runs.push(current);
|
||||
return runs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Inside one burst, the exposure identity is the compensation when it actually changes,
|
||||
* and the shutter when the body wrote the same compensation on every frame (manual brackets).
|
||||
* The next angle starts where that identity repeats.
|
||||
*/
|
||||
function splitByExposure(run: readonly BracketFrame[]): BracketFrame[][] {
|
||||
const useBias = distinct(run.map((frame) => biasKey(frame.exposureBias))) >= 2;
|
||||
const groups: BracketFrame[][] = [];
|
||||
let current: BracketFrame[] = [];
|
||||
const seen = new Set<number>();
|
||||
const close = () => {
|
||||
if (current.length === 0) return;
|
||||
groups.push(current);
|
||||
current = [];
|
||||
seen.clear();
|
||||
};
|
||||
for (const frame of run) {
|
||||
const key = useBias ? biasKey(frame.exposureBias) : shutterKey(frame.exposureTime);
|
||||
if (key !== null && seen.has(key)) close();
|
||||
current.push(frame);
|
||||
if (key !== null) seen.add(key);
|
||||
}
|
||||
close();
|
||||
return groups;
|
||||
}
|
||||
|
||||
function isStack(group: readonly BracketFrame[]): boolean {
|
||||
return group.length >= MIN_STACK_FRAMES && spanStops(group) >= MIN_SPAN_STOPS;
|
||||
}
|
||||
|
||||
function spanStops(group: readonly BracketFrame[]): number {
|
||||
const biases = group.map((frame) => frame.exposureBias).filter((value): value is number => value != null && Number.isFinite(value));
|
||||
if (distinct(biases.map((value) => biasKey(value))) >= 2) return Math.max(...biases) - Math.min(...biases);
|
||||
const times = group.map((frame) => frame.exposureTime).filter((value): value is number => value != null && value > 0);
|
||||
if (times.length < 2) return 0;
|
||||
return Math.log2(Math.max(...times) / Math.min(...times));
|
||||
}
|
||||
|
||||
function sameAngle(first: BracketFrame, frame: BracketFrame): boolean {
|
||||
if (!sameBody(first, frame)) return false;
|
||||
if (!closeNumber(first.focalLength, frame.focalLength, 0.02, 0)) return false;
|
||||
if (!closeNumber(first.aperture, frame.aperture, 0, 0.15)) return false;
|
||||
if (first.iso != null && frame.iso != null && first.iso !== frame.iso) return false;
|
||||
if (first.width != null && frame.width != null && first.width !== frame.width) return false;
|
||||
if (first.height != null && frame.height != null && first.height !== frame.height) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function sameBody(a: BracketFrame, b: BracketFrame): boolean {
|
||||
const aSerial = text(a.cameraSerial);
|
||||
const bSerial = text(b.cameraSerial);
|
||||
if (aSerial && bSerial) return aSerial === bSerial;
|
||||
const aName = cameraName(a);
|
||||
const bName = cameraName(b);
|
||||
if (aName && bName) return aName === bName;
|
||||
return true;
|
||||
}
|
||||
|
||||
function cameraName(frame: BracketFrame): string {
|
||||
return [text(frame.cameraMake), text(frame.cameraModel)].filter((part) => part !== "").join(" ").toLowerCase();
|
||||
}
|
||||
|
||||
function gapTooWide(prev: BracketFrame, next: BracketFrame): boolean {
|
||||
const gap = gapSeconds(prev, next);
|
||||
return gap !== null && gap > GAP_AFTER_EXPOSURE_SECONDS;
|
||||
}
|
||||
|
||||
/** Seconds from the end of `prev` to the start of `next`. Null when either clock is missing. */
|
||||
function gapSeconds(prev: BracketFrame, next: BracketFrame): number | null {
|
||||
const from = instant(prev);
|
||||
const to = instant(next);
|
||||
if (from === null || to === null) return null;
|
||||
const duration = prev.exposureTime != null && prev.exposureTime > 0 ? prev.exposureTime : 0;
|
||||
return (to - from) / 1000 - duration;
|
||||
}
|
||||
|
||||
function byCapture(a: BracketFrame, b: BracketFrame): number {
|
||||
const aAt = instant(a);
|
||||
const bAt = instant(b);
|
||||
if (aAt !== null && bAt !== null && aAt !== bAt) return aAt - bAt;
|
||||
const name = natural(a.fileName ?? "", b.fileName ?? "");
|
||||
if (name !== 0) return name;
|
||||
if (a.id < b.id) return -1;
|
||||
if (a.id > b.id) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
function instant(frame: BracketFrame): number | null {
|
||||
if (!frame.capturedAt) return null;
|
||||
const value = Date.parse(frame.capturedAt);
|
||||
return Number.isFinite(value) ? value : null;
|
||||
}
|
||||
|
||||
function biasKey(value: number | null | undefined): number | null {
|
||||
if (value == null || !Number.isFinite(value)) return null;
|
||||
return Math.round(value * 10) / 10;
|
||||
}
|
||||
|
||||
/** Two significant figures, so 1/100 and 1/400 differ and 1/100.1 does not. */
|
||||
function shutterKey(value: number | null | undefined): number | null {
|
||||
if (value == null || !Number.isFinite(value) || value <= 0) return null;
|
||||
const magnitude = 10 ** (Math.floor(Math.log10(value)) - 1);
|
||||
return Math.round(value / magnitude) * magnitude;
|
||||
}
|
||||
|
||||
function distinct(keys: readonly (number | null)[]): number {
|
||||
return new Set(keys.filter((key): key is number => key !== null)).size;
|
||||
}
|
||||
|
||||
function closeNumber(a: number | null | undefined, b: number | null | undefined, rel: number, abs: number): boolean {
|
||||
if (a == null || b == null || !Number.isFinite(a) || !Number.isFinite(b)) return true;
|
||||
return Math.abs(a - b) <= Math.max(abs, rel * Math.max(Math.abs(a), Math.abs(b)));
|
||||
}
|
||||
|
||||
function text(value: string | null | undefined): string {
|
||||
return value?.trim() ?? "";
|
||||
}
|
||||
|
||||
function natural(a: string, b: string): number {
|
||||
return a.localeCompare(b, undefined, { numeric: true, sensitivity: "base" });
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
export * from "./brackets.js";
|
||||
export * from "./codes.js";
|
||||
export * from "./iptc.js";
|
||||
export * from "./paths.js";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { BundleInput, BundleSummary, PressAccountInput, PressAccountSummary, PressStatement, NotificationView, AffiliateInput, AffiliateSummary, EarningsOverview, EarningsSettings, MemberPayoutInput, MyEarnings, PayeeAccount, PayoutInput, PayoutView, CodeGeneratorSettings, CodeLine, ConfirmFaceGroup, DeliveryItemSummary, DevelopState, EditLogEntry, FaceGroupSummary, GalleryInput, GalleryPhotosChange, GallerySummary, Module, OrderView, PhotoPatch, PhotoSummary, PostEdits, PrinterSummary, PrintEventInput, PrintEventSummary, PrintJobSummary, ProductInput, ProofingReport, ProductSummary, SiteInfo, SiteInput, StationSummary } from "@photoreport/contracts";
|
||||
import type { AgendaEntry, ArchiveStorage, CardScan, FaceIdentify, FaceRoster, CloudFolderSummary, CloudSource, CloudTreeFolder, InvoiceSummary, AutopilotStyle, DeliveryTarget, DeliveryTargetInput, JerseySample, JerseyStats, PersonSummary, PhotoFace, PhotoLookup, ShopSettings, SquadPerson, DeviceGrant, FtpAccount, FtpPlan, EventInput, EventSquads, EventSummary, FtpTargetAccount, IptcIssue, SportsCompetition, SportsFixture, SportsPlayer, SportsTeam, Me, Member, PhotoQuery, Role, ZerozeroGame } from "./types.js";
|
||||
import type { AgendaEntry, ArchiveStorage, CardScan, FaceIdentify, FaceRoster, CloudFolderSummary, CloudSource, CloudTreeFolder, InvoiceSummary, AutopilotStyle, DeliveryTarget, DeliveryTargetInput, JerseySample, JerseyStats, PersonSummary, PhotoFace, PhotoLookup, ShopSettings, SquadPerson, DeviceGrant, FtpAccount, FtpPlan, EventInput, EventSquads, EventSummary, FtpTargetAccount, IptcIssue, SportsCompetition, SportsFixture, SportsPlayer, SportsTeam, Me, Member, PhotoQuery, RealEstateFrame, RealEstateGrouping, Role, ZerozeroGame } from "./types.js";
|
||||
|
||||
/**
|
||||
* Where the refresh token lives. The web app leaves it in an httpOnly cookie (no store); the desktop app keeps it
|
||||
@@ -772,6 +772,20 @@ export class ApiClient {
|
||||
return this.request<{ enabled: boolean; legalBasis: string | null }>("PUT", `/v1/orgs/${orgId}/biometrics`, { enabled, ...(legalBasis ? { legalBasis } : {}) });
|
||||
}
|
||||
|
||||
getRealEstate(orgId: string) {
|
||||
return this.request<{ enabled: boolean }>("GET", `/v1/orgs/${orgId}/real-estate`);
|
||||
}
|
||||
|
||||
/** Owners show or hide the interior-bracket area. */
|
||||
setRealEstate(orgId: string, enabled: boolean) {
|
||||
return this.request<{ enabled: boolean }>("PUT", `/v1/orgs/${orgId}/real-estate`, { enabled });
|
||||
}
|
||||
|
||||
/** Groups exposure metadata into one stack per angle. The image files are not uploaded. */
|
||||
groupRealEstate(orgId: string, frames: RealEstateFrame[]) {
|
||||
return this.request<RealEstateGrouping>("POST", `/v1/orgs/${orgId}/real-estate/groups`, { frames });
|
||||
}
|
||||
|
||||
analyseEventFaces(eventId: string) {
|
||||
return this.request<{ queued: number }>("POST", `/v1/events/${eventId}/faces/analyse`);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,30 @@ export interface Organization {
|
||||
slug: string;
|
||||
name: string;
|
||||
mode: OrganizationMode;
|
||||
/** Interior brackets. Missing on a session saved before the area existed: treated as off. */
|
||||
realEstateEnabled?: boolean;
|
||||
}
|
||||
|
||||
/** One frame's exposure metadata. The file itself stays on the photographer's computer. */
|
||||
export interface RealEstateFrame {
|
||||
id: string;
|
||||
fileName?: string | null;
|
||||
capturedAt?: string | null;
|
||||
cameraSerial?: string | null;
|
||||
cameraMake?: string | null;
|
||||
cameraModel?: string | null;
|
||||
focalLength?: number | null;
|
||||
aperture?: number | null;
|
||||
iso?: number | null;
|
||||
width?: number | null;
|
||||
height?: number | null;
|
||||
exposureBias?: number | null;
|
||||
exposureTime?: number | null;
|
||||
}
|
||||
|
||||
export interface RealEstateGrouping {
|
||||
stacks: { frameIds: string[] }[];
|
||||
aside: string[];
|
||||
}
|
||||
|
||||
export interface Me {
|
||||
|
||||
@@ -9,6 +9,9 @@
|
||||
//! Settings from an op log:
|
||||
//! in: {"id": "...", "base": {..settings..} | null, "commands": [{"command": "develop.set", "params": {..}}, ..]}
|
||||
//! out: {"id": "...", "settings": {..}, "skipped": [indexes of commands that were refused], "unedited": bool}
|
||||
//! Capture metadata (LightCraft: EXIF, then IPTC, then XMP, including CR3 and a loose XMP sidecar):
|
||||
//! in: {"id": "...", "meta": {"input": "/abs/photo.cr3"}}
|
||||
//! out: {"id": "...", "capture": { "cameraMake": "..", "exposureTime": 0.01, "exposureBias": -2, .. }}
|
||||
|
||||
use std::io::{BufRead, Write};
|
||||
|
||||
@@ -149,6 +152,23 @@ fn run(job: &Job) -> Result<(u32, u32), String> {
|
||||
Ok((px.width, px.height))
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct MetaRequest {
|
||||
id: String,
|
||||
meta: MetaJob,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct MetaJob {
|
||||
input: String,
|
||||
}
|
||||
|
||||
/// Capture metadata of one file. The same JSON the browser engine returns.
|
||||
fn capture_file(path: &str) -> Result<serde_json::Value, String> {
|
||||
let bytes = std::fs::read(path).map_err(|e| format!("{path}: {e}"))?;
|
||||
Ok(photoreport_engine::capture::read_capture(&bytes))
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let stdout = std::io::stdout();
|
||||
let mut out = stdout.lock();
|
||||
@@ -171,6 +191,20 @@ fn main() {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
if value.get("meta").is_some() {
|
||||
let reply = match serde_json::from_value::<MetaRequest>(value) {
|
||||
Ok(req) => match capture_file(&req.meta.input) {
|
||||
Ok(capture) => serde_json::json!({ "id": req.id, "capture": capture }),
|
||||
Err(error) => serde_json::json!({ "id": req.id, "error": error }),
|
||||
},
|
||||
Err(e) => {
|
||||
serde_json::json!({ "id": serde_json::Value::Null, "error": format!("bad request: {e}") })
|
||||
}
|
||||
};
|
||||
let _ = writeln!(out, "{reply}");
|
||||
let _ = out.flush();
|
||||
continue;
|
||||
}
|
||||
if value.get("auto").is_some() {
|
||||
let reply = match serde_json::from_value::<AutoRequest>(value) {
|
||||
Ok(req) => match auto(&req.auto) {
|
||||
@@ -219,7 +253,13 @@ fn main() {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::{DevelopSettings, decode_edge};
|
||||
use super::{DevelopSettings, capture_file, decode_edge};
|
||||
|
||||
#[test]
|
||||
fn a_missing_file_is_an_error() {
|
||||
let err = capture_file("/no/such/photo.cr3").unwrap_err();
|
||||
assert!(err.contains("photo.cr3"), "{err}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_tight_crop_decodes_enough_for_the_output() {
|
||||
|
||||
Reference in new issue
Block a user