Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat (ai): image compression (#197)

Eric Hayes9fda15434ac1
diff --git a/rust/cloud-storage/Cargo.lock b/rust/cloud-storage/Cargo.lock
index 6d1d10c78c..d405a0a36f 100644
--- a/rust/cloud-storage/Cargo.lock
+++ b/rust/cloud-storage/Cargo.lock
@@ -108,12 +108,30 @@ dependencies = [
"uuid",
]
+[[package]]
+name = "aligned"
+version = "0.4.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "377e4c0ba83e4431b10df45c1d4666f178ea9c552cac93e60c3a88bf32785923"
+dependencies = [
+ "as-slice",
+]
+
[[package]]
name = "aligned-vec"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4aa90d7ce82d4be67b64039a3d588d38dbcc6736577de4a847025ce5b0c468d1"
+[[package]]
+name = "aligned-vec"
+version = "0.6.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "dc890384c8602f339876ded803c97ad529f3842aba97f6392b3dba0dd171769b"
+dependencies = [
+ "equator",
+]
+
[[package]]
name = "allocator-api2"
version = "0.2.21"
@@ -256,6 +274,15 @@ version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50"
+[[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 = "async-channel"
version = "1.9.0"
@@ -532,6 +559,26 @@ version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
+[[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 2.0.17",
+ "v_frame",
+ "y4m",
+]
+
[[package]]
name = "av1-grain"
version = "0.2.3"
@@ -548,9 +595,9 @@ dependencies = [
[[package]]
name = "avif-serialize"
-version = "0.8.2"
+version = "0.8.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "e335041290c43101ca215eed6f43ec437eb5a42125573f600fc3fa42b9bddd62"
+checksum = "47c8fbc0f831f4519fe8b810b6a7a91410ec83031b8233f730a0480029f6a23f"
dependencies = [
"arrayvec",
]
@@ -1288,7 +1335,7 @@ version = "0.71.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f58bf3d7db68cfbac37cfc485a8d711e87e064c3d0fe0435b92f7a407f9d6b3"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
"cexpr",
"clang-sys",
"itertools 0.12.1",
@@ -1323,12 +1370,6 @@ version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dc827186963e592360843fb5ba4b973e145841266c1357f7180c43526f2e5b61"
-[[package]]
-name = "bitflags"
-version = "1.3.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
-
[[package]]
name = "bitflags"
version = "2.8.0"
@@ -1340,9 +1381,12 @@ dependencies = [
[[package]]
name = "bitstream-io"
-version = "2.6.0"
+version = "4.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "6099cdc01846bc367c4e7dd630dc5966dccf36b652fae7a74e17b640411a91b2"
+checksum = "60d4bd9d1db2c6bdf285e223a7fa369d5ce98ec767dec949c6ca62863ce61757"
+dependencies = [
+ "core2",
+]
[[package]]
name = "block-buffer"
@@ -1375,9 +1419,9 @@ dependencies = [
[[package]]
name = "built"
-version = "0.7.6"
+version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "73848a43c5d63a1251d17adf6c2bf78aa94830e60a335a95eeea45d6ba9e1e4d"
+checksum = "f4ad8f11f288f48ca24471bbd51ac257aaeaaa07adae295591266b792902ae64"
[[package]]
name = "bumpalo"
@@ -1509,16 +1553,6 @@ dependencies = [
"uuid",
]
-[[package]]
-name = "cfg-expr"
-version = "0.15.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "d067ad48b8650848b989a59a86c6c36a995d02d2bf778d45c3c5d57bc2718f02"
-dependencies = [
- "smallvec",
- "target-lexicon",
-]
-
[[package]]
name = "cfg-if"
version = "1.0.0"
@@ -1978,6 +2012,15 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
+[[package]]
+name = "core2"
+version = "0.4.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "b49ba7ef1ad6107f8824dbe97de947cbaac53c44e7f9756a1fba0d37c1eec505"
+dependencies = [
+ "memchr",
+]
+
[[package]]
name = "cpufeatures"
version = "0.2.17"
@@ -2926,6 +2969,26 @@ dependencies = [
"tracing",
]
+[[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.98",
+]
+
[[package]]
name = "equivalent"
version = "1.0.1"
@@ -3018,9 +3081,9 @@ dependencies = [
[[package]]
name = "exr"
-version = "1.73.0"
+version = "1.74.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f83197f59927b46c04a183a619b7c29df34e63e63c7869320862268c0ef687e0"
+checksum = "4300e043a56aa2cb633c01af81ca8f699a321879a7854d3896a0ba89056363be"
dependencies = [
"bit_field",
"half",
@@ -3056,6 +3119,26 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
+[[package]]
+name = "fax"
+version = "0.2.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "f05de7d48f37cd6730705cbca900770cab77a89f413d23e100ad7fad7795a0ab"
+dependencies = [
+ "fax_derive",
+]
+
+[[package]]
+name = "fax_derive"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a0aca10fb742cb43f9e7bb8467c91aa9bcb8e3ffbc6a6f7389bb93ffc920577d"
+dependencies = [
+ "proc-macro2",
+ "quote",
+ "syn 2.0.98",
+]
+
[[package]]
name = "fdeflate"
version = "0.3.7"
@@ -3385,9 +3468,9 @@ dependencies = [
[[package]]
name = "gif"
-version = "0.13.1"
+version = "0.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "3fb2d69b19215e18bb912fa30f7ce15846e301408695e44e0ef719f1da9e19f2"
+checksum = "f954a9e9159ec994f73a30a12b96a702dde78f5547bcb561174597924f7d4162"
dependencies = [
"color_quant",
"weezl",
@@ -4017,9 +4100,9 @@ dependencies = [
[[package]]
name = "image"
-version = "0.25.5"
+version = "0.25.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cd6f44aed642f18953a158afeb30206f4d50da59fbc66ecb53c66488de73563b"
+checksum = "e6506c6c10786659413faa717ceebcb8f70731c0a60cbae39795fdf114519c1a"
dependencies = [
"bytemuck",
"byteorder-lite",
@@ -4027,6 +4110,7 @@ dependencies = [
"exr",
"gif",
"image-webp",
+ "moxcms",
"num-traits",
"png",
"qoi",
@@ -4034,8 +4118,8 @@ dependencies = [
"rayon",
"rgb",
"tiff",
- "zune-core",
- "zune-jpeg",
+ "zune-core 0.5.0",
+ "zune-jpeg 0.5.5",
]
[[package]]
@@ -4268,12 +4352,6 @@ dependencies = [
"libc",
]
-[[package]]
-name = "jpeg-decoder"
-version = "0.3.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f5d4a7da358eff58addd2877a45865158f0d78c911d43a5784ceb7bbf52833b0"
-
[[package]]
name = "js-sys"
version = "0.3.77"
@@ -4436,6 +4514,16 @@ dependencies = [
"vcpkg",
]
+[[package]]
+name = "libwebp-sys"
+version = "0.9.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "54cd30df7c7165ce74a456e4ca9732c603e8dc5e60784558c1c6dc047f876733"
+dependencies = [
+ "cc",
+ "glob",
+]
+
[[package]]
name = "linux-raw-sys"
version = "0.9.4"
@@ -4476,7 +4564,7 @@ version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26a24302899fc10d7a785ea5d810ba3c41faa37d0f77847d9f0b16195d3c7a6c"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
"cfg-if",
"cssparser 0.35.0",
"encoding_rs",
@@ -5357,6 +5445,16 @@ dependencies = [
"uuid",
]
+[[package]]
+name = "moxcms"
+version = "0.7.9"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "0fbdd3d7436f8b5e892b8b7ea114271ff0fa00bc5acae845d53b07d498616ef6"
+dependencies = [
+ "num-traits",
+ "pxfm",
+]
+
[[package]]
name = "multer"
version = "3.1.0"
@@ -5403,7 +5501,7 @@ version = "0.29.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
"cfg-if",
"cfg_aliases",
"libc",
@@ -5670,7 +5768,7 @@ version = "0.10.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
"cfg-if",
"foreign-types",
"libc",
@@ -5860,6 +5958,12 @@ 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 = "pbkdf2"
version = "0.12.2"
@@ -5876,7 +5980,7 @@ version = "0.8.30"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2773a939ec2c736640f5f2e62a325c2e1a997d694961c50f17cadfb4c8682e84"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
"bytemuck",
"bytes",
"chrono",
@@ -6097,11 +6201,11 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
[[package]]
name = "png"
-version = "0.17.16"
+version = "0.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "82151a2fc869e011c153adc57cf2789ccb8d9906ce52c0b39a6b5697749d7526"
+checksum = "97baced388464909d42d89643fe4361939af9b7ce7a31ee32a168f832a70f2a0"
dependencies = [
- "bitflags 1.3.2",
+ "bitflags",
"crc32fast",
"fdeflate",
"flate2",
@@ -6285,6 +6389,15 @@ dependencies = [
"tracing",
]
+[[package]]
+name = "pxfm"
+version = "0.1.25"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a3cbdf373972bf78df4d3b518d07003938e2c7d1fb5891e55f9cb6df57009d84"
+dependencies = [
+ "num-traits",
+]
+
[[package]]
name = "qoi"
version = "0.4.1"
@@ -6471,19 +6584,21 @@ dependencies = [
[[package]]
name = "rav1e"
-version = "0.7.1"
+version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cd87ce80a7665b1cce111f8a16c1f3929f6547ce91ade6addf4ec86a8dda5ce9"
+checksum = "43b6dd56e85d9483277cde964fd1bdb0428de4fec5ebba7540995639a21cb32b"
dependencies = [
+ "aligned-vec 0.6.4",
"arbitrary",
"arg_enum_proc_macro",
"arrayvec",
+ "av-scenechange",
"av1-grain",
"bitstream-io",
"built",
"cfg-if",
"interpolate_name",
- "itertools 0.12.1",
+ "itertools 0.14.0",
"libc",
"libfuzzer-sys",
"log",
@@ -6492,23 +6607,21 @@ dependencies = [
"noop_proc_macro",
"num-derive",
"num-traits",
- "once_cell",
"paste",
"profiling",
- "rand 0.8.5",
- "rand_chacha 0.3.1",
+ "rand 0.9.0",
+ "rand_chacha 0.9.0",
"simd_helpers",
- "system-deps",
- "thiserror 1.0.69",
+ "thiserror 2.0.17",
"v_frame",
"wasm-bindgen",
]
[[package]]
name = "ravif"
-version = "0.11.11"
+version = "0.12.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2413fd96bd0ea5cdeeb37eaf446a22e6ed7b981d792828721e74ded1980a45c6"
+checksum = "ef69c1990ceef18a116855938e74793a5f7496ee907562bd0857b6ac734ab285"
dependencies = [
"avif-serialize",
"imgref",
@@ -6579,7 +6692,7 @@ version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03a862b389f93e68874fbf580b9de08dd02facb9a788ebadaf4a3fd33cf58834"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
]
[[package]]
@@ -6874,7 +6987,7 @@ version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d97817398dd4bb2e6da002002db259209759911da105da92bec29ccb12cf58bf"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
"errno",
"libc",
"linux-raw-sys",
@@ -7087,6 +7200,7 @@ dependencies = [
"document_storage_service_client",
"email_service_client",
"futures",
+ "image",
"lexical_client",
"macro_client_errors",
"model",
@@ -7104,6 +7218,7 @@ dependencies = [
"tokio",
"tracing",
"uuid",
+ "webp",
]
[[package]]
@@ -7271,7 +7386,7 @@ version = "2.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
"core-foundation 0.9.4",
"core-foundation-sys",
"libc",
@@ -7284,7 +7399,7 @@ version = "3.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "271720403f46ca04f7ba6f55d438f8bd878d6b8ca0a1046e8228c4145bcbb316"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
"core-foundation 0.10.0",
"core-foundation-sys",
"libc",
@@ -7307,7 +7422,7 @@ version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4eb30575f3638fc8f6815f448d50cb1a2e255b0897985c8c59f4d37b72a07b06"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
"cssparser 0.31.2",
"derive_more",
"fxhash",
@@ -7326,7 +7441,7 @@ version = "0.27.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b75e048a93e14929e68e37b82e207db957cbb368375a80ed3ca28ac75080856"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
"cssparser 0.35.0",
"derive_more",
"fxhash",
@@ -7455,15 +7570,6 @@ dependencies = [
"syn 2.0.98",
]
-[[package]]
-name = "serde_spanned"
-version = "0.6.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1"
-dependencies = [
- "serde",
-]
-
[[package]]
name = "serde_urlencoded"
version = "0.7.1"
@@ -7926,7 +8032,7 @@ checksum = "aa003f0038df784eb8fecbbac13affe3da23b45194bd57dba231c8f48199c526"
dependencies = [
"atoi",
"base64 0.22.1",
- "bitflags 2.8.0",
+ "bitflags",
"byteorder",
"bytes",
"chrono",
@@ -7970,7 +8076,7 @@ checksum = "db58fcd5a53cf07c184b154801ff91347e4c30d17a3562a635ff028ad5deda46"
dependencies = [
"atoi",
"base64 0.22.1",
- "bitflags 2.8.0",
+ "bitflags",
"byteorder",
"chrono",
"crc",
@@ -8235,7 +8341,7 @@ version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
"core-foundation 0.9.4",
"system-configuration-sys",
]
@@ -8250,25 +8356,6 @@ dependencies = [
"libc",
]
-[[package]]
-name = "system-deps"
-version = "6.2.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a3e535eb8dded36d55ec13eddacd30dec501792ff23a0b1682c38601b8cf2349"
-dependencies = [
- "cfg-expr",
- "heck",
- "pkg-config",
- "toml",
- "version-compare",
-]
-
-[[package]]
-name = "target-lexicon"
-version = "0.12.16"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "61c41af27dd6d1e27b1b16b489db798443478cef1f06a660c96db617ba5de3b1"
-
[[package]]
name = "teams"
version = "0.1.0"
@@ -8397,13 +8484,16 @@ dependencies = [
[[package]]
name = "tiff"
-version = "0.9.1"
+version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "ba1310fcea54c6a9a4fd1aad794ecc02c31682f6bfbecdf460bf19533eed1e3e"
+checksum = "af9605de7fee8d9551863fd692cce7637f548dbd9db9180fcc07ccc6d26c336f"
dependencies = [
+ "fax",
"flate2",
- "jpeg-decoder",
+ "half",
+ "quick-error",
"weezl",
+ "zune-jpeg 0.4.21",
]
[[package]]
@@ -8571,40 +8661,6 @@ dependencies = [
"tokio",
]
-[[package]]
-name = "toml"
-version = "0.8.20"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "cd87a5cdd6ffab733b2f74bc4fd7ee5fff6634124999ac278c35fc78c6120148"
-dependencies = [
- "serde",
- "serde_spanned",
- "toml_datetime",
- "toml_edit",
-]
-
-[[package]]
-name = "toml_datetime"
-version = "0.6.8"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41"
-dependencies = [
- "serde",
-]
-
-[[package]]
-name = "toml_edit"
-version = "0.22.24"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "17b4795ff5edd201c7cd6dca065ae59972ce77d1b80fa0a84d94950ece7d1474"
-dependencies = [
- "indexmap 2.7.1",
- "serde",
- "serde_spanned",
- "toml_datetime",
- "winnow",
-]
-
[[package]]
name = "tower"
version = "0.4.13"
@@ -8660,7 +8716,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2"
dependencies = [
"async-compression",
- "bitflags 2.8.0",
+ "bitflags",
"bytes",
"futures-core",
"futures-util",
@@ -9117,7 +9173,7 @@ version = "0.3.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6f32aaa24bacd11e488aa9ba66369c7cd514885742c9fe08cfe85884db3e92b"
dependencies = [
- "aligned-vec",
+ "aligned-vec 0.5.0",
"num-traits",
"wasm-bindgen",
]
@@ -9143,12 +9199,6 @@ dependencies = [
"piston-float",
]
-[[package]]
-name = "version-compare"
-version = "0.2.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "852e951cb7832cb45cb1169900d19760cfa39b82bc0ea9c0e5a14ae88411c98b"
-
[[package]]
name = "version_check"
version = "0.9.5"
@@ -9334,6 +9384,16 @@ dependencies = [
"string_cache_codegen",
]
+[[package]]
+name = "webp"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "c071456adef4aca59bf6a583c46b90ff5eb0b4f758fc347cea81290288f37ce1"
+dependencies = [
+ "image",
+ "libwebp-sys",
+]
+
[[package]]
name = "webpki-roots"
version = "0.26.11"
@@ -9354,9 +9414,9 @@ dependencies = [
[[package]]
name = "weezl"
-version = "0.1.8"
+version = "0.1.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "53a85b86a771b1c87058196170769dd264f66c0782acf1ae6cc51bfd64b39082"
+checksum = "a28ac98ddc8b9274cb41bb4d9d4d5c425b6020c50c46f25559911905610b4a88"
[[package]]
name = "whoami"
@@ -9658,22 +9718,13 @@ version = "0.53.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650"
-[[package]]
-name = "winnow"
-version = "0.7.2"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "59690dea168f2198d1a3b0cac23b8063efcd11012f10ae4698f284808c8ef603"
-dependencies = [
- "memchr",
-]
-
[[package]]
name = "wit-bindgen-rt"
version = "0.33.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c"
dependencies = [
- "bitflags 2.8.0",
+ "bitflags",
]
[[package]]
@@ -9719,6 +9770,12 @@ dependencies = [
"lzma-sys",
]
+[[package]]
+name = "y4m"
+version = "0.8.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7a5a4b21e1a62b67a2970e6831bc091d7b87e119e7f9791aef9702e3bef04448"
+
[[package]]
name = "yansi"
version = "1.0.1"
@@ -9931,6 +9988,12 @@ version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f423a2c17029964870cfaabb1f13dfab7d092a62a29a89264f4d36990ca414a"
+[[package]]
+name = "zune-core"
+version = "0.5.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "111f7d9820f05fd715df3144e254d6fc02ee4088b0644c0ffd0efc9e6d9d2773"
+
[[package]]
name = "zune-inflate"
version = "0.2.54"
@@ -9942,9 +10005,18 @@ dependencies = [
[[package]]
name = "zune-jpeg"
-version = "0.4.14"
+version = "0.4.21"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "29ce2c8a9384ad323cf564b67da86e21d3cfdff87908bc1223ed5c99bc792713"
+dependencies = [
+ "zune-core 0.4.12",
+]
+
+[[package]]
+name = "zune-jpeg"
+version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "99a5bab8d7dedf81405c4bb1f2b83ea057643d9cb28778cea9eecddeedd2e028"
+checksum = "dc6fb7703e32e9a07fb3f757360338b3a567a5054f21b5f52a666752e333d58e"
dependencies = [
- "zune-core",
+ "zune-core 0.5.0",
]
diff --git a/rust/cloud-storage/document_cognition_service/src/service/attachment/fetch.rs b/rust/cloud-storage/document_cognition_service/src/service/attachment/fetch.rs
index 618e07ef19..5eb6018809 100644
--- a/rust/cloud-storage/document_cognition_service/src/service/attachment/fetch.rs
+++ b/rust/cloud-storage/document_cognition_service/src/service/attachment/fetch.rs
@@ -31,7 +31,7 @@ pub async fn fetchium(
.await
.context("failed to fetch image content")?
.content
- .base64_image_content()?;
+ .base64_compressed_webp()?;
Ok(Attachment::ImageUrl(base64_image))
}
@@ -63,7 +63,7 @@ pub async fn fetchium(
.context("failed to fetch document content")?;
if document.file_type().is_image() {
Ok(Attachment::ImageUrl(
- document.content.base64_image_content()?,
+ document.content.base64_compressed_webp()?,
))
} else {
Ok(Attachment::Text(PromptAttachment {
diff --git a/rust/cloud-storage/model/src/document/file_type/mod.rs b/rust/cloud-storage/model/src/document/file_type/mod.rs
index 97aceb8e9b..2eac71c7d8 100644
--- a/rust/cloud-storage/model/src/document/file_type/mod.rs
+++ b/rust/cloud-storage/model/src/document/file_type/mod.rs
@@ -59,7 +59,12 @@ impl FileTypeExt for FileType {
fn is_image(&self) -> bool {
matches!(
self,
- FileType::Png | FileType::Jpg | FileType::Gif | FileType::Svg | FileType::Jpeg
+ FileType::Png
+ | FileType::Jpg
+ | FileType::Jpeg
+ | FileType::Gif
+ | FileType::Svg
+ | FileType::Webp
)
}
diff --git a/rust/cloud-storage/scribe/Cargo.toml b/rust/cloud-storage/scribe/Cargo.toml
index 36dd32a6fe..531fa8f9c3 100644
--- a/rust/cloud-storage/scribe/Cargo.toml
+++ b/rust/cloud-storage/scribe/Cargo.toml
@@ -56,3 +56,5 @@ models_comms = { path = "../models_comms", optional = true }
models_email = { path = "../models_email", optional = true }
models_sfs = { path = "../models_sfs", optional = true }
static_file_service_client = { path = "../static_file_service_client", optional = true }
+image = "0.25.9"
+webp = "0.3.1"
diff --git a/rust/cloud-storage/scribe/src/compress_image.rs b/rust/cloud-storage/scribe/src/compress_image.rs
new file mode 100644
index 0000000000..5b4d4a1656
--- /dev/null
+++ b/rust/cloud-storage/scribe/src/compress_image.rs
@@ -0,0 +1,38 @@
+use anyhow::Result;
+use base64::Engine;
+use base64::engine::general_purpose;
+use image::{DynamicImage, GenericImageView};
+use webp::Encoder;
+
+const ENCODING_QUALITY: f32 = 75.0;
+const MAX_SIZE_W: u32 = 1080;
+const MAX_SIZE_H: u32 = 720;
+
+pub fn make_compressed_base64_webp(image_bytes: &[u8]) -> Result<String> {
+ let img = image::load_from_memory(image_bytes)?;
+ let resized_img = resize_if_needed(img);
+ let rgb_img = resized_img.to_rgb8();
+ let encoder = Encoder::from_rgb(&rgb_img, rgb_img.width(), rgb_img.height());
+ let webp_data = encoder.encode(ENCODING_QUALITY);
+ let base64_string = general_purpose::STANDARD.encode(&*webp_data);
+ Ok(format!("data:image/webp;base64,{}", base64_string))
+}
+
+fn resize_if_needed(img: DynamicImage) -> DynamicImage {
+ let (width, height) = img.dimensions();
+
+ // Check if resize is needed
+ if width <= MAX_SIZE_W && height <= MAX_SIZE_H {
+ return img;
+ }
+
+ // Calculate new dimensions while maintaining aspect ratio
+ let width_ratio = MAX_SIZE_W as f32 / width as f32;
+ let height_ratio = MAX_SIZE_H as f32 / height as f32;
+ let ratio = width_ratio.min(height_ratio);
+
+ let new_width = (width as f32 * ratio) as u32;
+ let new_height = (height as f32 * ratio) as u32;
+
+ img.resize(new_width, new_height, image::imageops::FilterType::Lanczos3)
+}
diff --git a/rust/cloud-storage/scribe/src/document/types.rs b/rust/cloud-storage/scribe/src/document/types.rs
index 30faf9a98c..02ea1e1d81 100644
--- a/rust/cloud-storage/scribe/src/document/types.rs
+++ b/rust/cloud-storage/scribe/src/document/types.rs
@@ -1,5 +1,5 @@
+use crate::compress_image::make_compressed_base64_webp;
use anyhow::Error;
-use base64::{Engine as _, engine::general_purpose};
use bytes::Bytes;
use lexical_client::types::CognitionResponseData;
use model::document::response::LocationResponseV3;
@@ -47,12 +47,11 @@ impl DocumentContent {
}
#[tracing::instrument(err)]
- pub fn base64_image_content(self) -> Result<String, Error> {
- let data = self.data.binary_data();
- if self.file_type.is_image() && data.is_some() {
- let base64_string = general_purpose::STANDARD.encode(data.unwrap());
- let content_type = self.file_type.mime_type();
- Ok(format!("data:{};base64,{}", content_type, base64_string))
+ pub fn base64_compressed_webp(self) -> Result<String, Error> {
+ if self.file_type.is_image()
+ && let Some(bytes) = self.data.binary_data()
+ {
+ make_compressed_base64_webp(&bytes)
} else {
Err(anyhow::anyhow!("Data is not in image format"))
}
diff --git a/rust/cloud-storage/scribe/src/lib.rs b/rust/cloud-storage/scribe/src/lib.rs
index 9cccdaa413..f6b4cb2c38 100644
--- a/rust/cloud-storage/scribe/src/lib.rs
+++ b/rust/cloud-storage/scribe/src/lib.rs
@@ -1,6 +1,7 @@
#[cfg(feature = "channel")]
pub mod channel;
+mod compress_image;
#[cfg(feature = "dcs")]
pub mod dcs;
#[cfg(feature = "document")]
diff --git a/rust/cloud-storage/scribe/src/static_file/fetcher.rs b/rust/cloud-storage/scribe/src/static_file/fetcher.rs
index f221df4ae7..4d6f91465b 100644
--- a/rust/cloud-storage/scribe/src/static_file/fetcher.rs
+++ b/rust/cloud-storage/scribe/src/static_file/fetcher.rs
@@ -1,4 +1,4 @@
-use crate::static_file::types::{StaticFileContent, StaticFileData};
+use crate::static_file::types::{Data, StaticFileContent};
use anyhow::{Context, Error};
use model::document::{ContentType, ContentTypeExt};
use models_sfs::FileMetadata;
@@ -100,13 +100,13 @@ impl<L: Debug, D: Debug> StaticFileFetcher<L, D> {
.context("Failed to read file data")?;
let data = if content_type.is_image() {
- StaticFileData::Binary(file_data)
+ Data::Binary(file_data)
} else if content_type.is_text_content() {
let text = String::from_utf8(file_data.to_vec())
.context("Failed to convert file data to text")?;
- StaticFileData::Text(text)
+ Data::Text(text)
} else {
- StaticFileData::Binary(file_data)
+ Data::Binary(file_data)
};
Ok(StaticFileContent {
diff --git a/rust/cloud-storage/scribe/src/static_file/mod.rs b/rust/cloud-storage/scribe/src/static_file/mod.rs
index 8f07d3d40e..c68a3ac250 100644
--- a/rust/cloud-storage/scribe/src/static_file/mod.rs
+++ b/rust/cloud-storage/scribe/src/static_file/mod.rs
@@ -7,7 +7,7 @@ pub use client::StaticFileClient;
pub use fetcher::{NewStaticFileFetcher, StaticFileFetcher};
use static_file_service_client::StaticFileServiceClient;
use std::sync::Arc;
-pub use types::{StaticFileContent, StaticFileData};
+pub use types::{Data, StaticFileContent};
impl<D, C, A, E, S> ScribeClient<D, C, A, E, S> {
pub fn with_static_file_client<T: Into<Arc<StaticFileServiceClient>>>(
diff --git a/rust/cloud-storage/scribe/src/static_file/types.rs b/rust/cloud-storage/scribe/src/static_file/types.rs
index f4f53b11b2..612f94d00f 100644
--- a/rust/cloud-storage/scribe/src/static_file/types.rs
+++ b/rust/cloud-storage/scribe/src/static_file/types.rs
@@ -1,23 +1,19 @@
+use crate::compress_image::make_compressed_base64_webp;
use anyhow::Error;
-use base64::{Engine as _, engine::general_purpose};
-use bytes::Bytes;
use model::document::{ContentType, ContentTypeExt};
+
use models_sfs::FileMetadata;
+pub type Data = crate::document::types::Data;
+
#[derive(Debug, Clone)]
pub struct StaticFileContent {
- pub(crate) data: StaticFileData,
+ pub(crate) data: Data,
pub file_id: String,
pub content_type: ContentType,
pub metadata: FileMetadata,
}
-#[derive(Clone, Debug)]
-pub enum StaticFileData {
- Text(String),
- Binary(Bytes),
-}
-
impl StaticFileContent {
pub fn metadata(&self) -> &FileMetadata {
&self.metadata
@@ -34,41 +30,13 @@ impl StaticFileContent {
}
#[tracing::instrument(err)]
- pub fn base64_image_content(self) -> Result<String, Error> {
- let data = self.data.binary_data();
- if self.content_type.is_image() && data.is_some() {
- let base64_string = general_purpose::STANDARD.encode(data.unwrap());
- let content_type = self.content_type.mime_type();
- Ok(format!("data:{};base64,{}", content_type, base64_string))
+ pub fn base64_compressed_webp(self) -> Result<String, Error> {
+ if self.content_type.is_image()
+ && let Some(bytes) = self.data.binary_data()
+ {
+ make_compressed_base64_webp(&bytes)
} else {
Err(anyhow::anyhow!("Data is not in image format"))
}
}
}
-
-impl std::fmt::Display for StaticFileData {
- fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
- match self {
- StaticFileData::Binary(data) => write!(f, "{}", String::from_utf8_lossy(data)),
- StaticFileData::Text(text) => write!(f, "{}", text),
- }
- }
-}
-
-impl StaticFileData {
- pub fn binary_data(self) -> Option<Bytes> {
- if let StaticFileData::Binary(data) = self {
- Some(data)
- } else {
- None
- }
- }
-
- pub fn text_data(self) -> Option<String> {
- if let StaticFileData::Text(data) = self {
- Some(data)
- } else {
- None
- }
- }
-}