From ed977dbeda77ac4a16c681e2b2dca5c268a8b993 Mon Sep 17 00:00:00 2001 From: natea-oai Date: Mon, 9 Feb 2026 14:47:22 -0800 Subject: [PATCH] adding image support for gif and webp (#11237) Adds image support for gif and webp images. Tested using webp and gif (both single and multi image gif files) --- codex-rs/Cargo.lock | 29 +++++++++++++++++++ codex-rs/tui/Cargo.toml | 2 +- codex-rs/tui/src/bottom_pane/chat_composer.rs | 6 +++- codex-rs/utils/image/Cargo.toml | 4 +-- 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/codex-rs/Cargo.lock b/codex-rs/Cargo.lock index 3a3a60172..f5c1b5b29 100644 --- a/codex-rs/Cargo.lock +++ b/codex-rs/Cargo.lock @@ -2382,6 +2382,12 @@ dependencies = [ "tracing-error", ] +[[package]] +name = "color_quant" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" + [[package]] name = "colorchoice" version = "1.0.4" @@ -3877,6 +3883,16 @@ dependencies = [ "wasm-bindgen", ] +[[package]] +name = "gif" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f5df2ba84018d80c213569363bdcd0c64e6933c67fe4c1d60ecf822971a3c35e" +dependencies = [ + "color_quant", + "weezl", +] + [[package]] name = "gimli" version = "0.32.3" @@ -4524,6 +4540,9 @@ checksum = "e6506c6c10786659413faa717ceebcb8f70731c0a60cbae39795fdf114519c1a" dependencies = [ "bytemuck", "byteorder-lite", + "color_quant", + "gif", + "image-webp", "moxcms", "num-traits", "png", @@ -4532,6 +4551,16 @@ dependencies = [ "zune-jpeg 0.5.12", ] +[[package]] +name = "image-webp" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "525e9ff3e1a4be2fbea1fdf0e98686a6d98b4d8f937e1bf7402245af1909e8c3" +dependencies = [ + "byteorder-lite", + "quick-error", +] + [[package]] name = "impl-more" version = "0.1.9" diff --git a/codex-rs/tui/Cargo.toml b/codex-rs/tui/Cargo.toml index 8bdd47322..3252912ba 100644 --- a/codex-rs/tui/Cargo.toml +++ b/codex-rs/tui/Cargo.toml @@ -51,7 +51,7 @@ derive_more = { workspace = true, features = ["is_variant"] } diffy = { workspace = true } dirs = { workspace = true } dunce = { workspace = true } -image = { workspace = true, features = ["jpeg", "png"] } +image = { workspace = true, features = ["jpeg", "png", "gif", "webp"] } itertools = { workspace = true } lazy_static = { workspace = true } pathdiff = { workspace = true } diff --git a/codex-rs/tui/src/bottom_pane/chat_composer.rs b/codex-rs/tui/src/bottom_pane/chat_composer.rs index 93b3a5eec..c14cbc082 100644 --- a/codex-rs/tui/src/bottom_pane/chat_composer.rs +++ b/codex-rs/tui/src/bottom_pane/chat_composer.rs @@ -1540,7 +1540,11 @@ impl ChatComposer { fn is_image_path(path: &str) -> bool { let lower = path.to_ascii_lowercase(); - lower.ends_with(".png") || lower.ends_with(".jpg") || lower.ends_with(".jpeg") + lower.ends_with(".png") + || lower.ends_with(".jpg") + || lower.ends_with(".jpeg") + || lower.ends_with(".gif") + || lower.ends_with(".webp") } fn trim_text_elements( diff --git a/codex-rs/utils/image/Cargo.toml b/codex-rs/utils/image/Cargo.toml index b523de510..370249738 100644 --- a/codex-rs/utils/image/Cargo.toml +++ b/codex-rs/utils/image/Cargo.toml @@ -9,11 +9,11 @@ workspace = true [dependencies] base64 = { workspace = true } -image = { workspace = true, features = ["jpeg", "png"] } +image = { workspace = true, features = ["jpeg", "png", "gif", "webp"] } codex-utils-cache = { workspace = true } thiserror = { workspace = true } tokio = { workspace = true, features = ["fs", "rt", "rt-multi-thread", "macros"] } [dev-dependencies] -image = { workspace = true, features = ["jpeg", "png"] } +image = { workspace = true, features = ["jpeg", "png", "gif", "webp"] } tempfile = { workspace = true }