PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Codecs: open Amiga IFF/ILBM bitmaps read-only
Vikram Bhaskaranab596db6ae46
diff --git a/apps/photocraft-web/src/web.rs b/apps/photocraft-web/src/web.rsindex a5c9d8a56..fa2d98d64 100644--- a/apps/photocraft-web/src/web.rs+++ b/apps/photocraft-web/src/web.rs@@ -18,7 +18,7 @@ type Inbox = Arc<Mutex<Vec<(String, Vec<u8>)>>>;/// Photoshop brushes (.abr), gradients (.grd) and swatches (.aco, .ase), which go to the preset libraries.const OPEN_EXTS: &[&str] = &["pcraft", "pdn", "ora", "kra", "krz", "psd", "psb", "psdt", "png", "jpg", "jpeg", "tif", "tiff", "webp", "gif", "bmp", "tga", "ico", "qoi", "exr", "hdr",- "pbm", "pgm", "ppm", "pam", "pfm", "dds", "fits", "fit", "fts", "dpx", "heic", "heif", "hif", "dng", "cr2", "cr3", "nef", "nrw", "arw", "pef", "orf",+ "pbm", "pgm", "ppm", "pam", "pfm", "dds", "fits", "fit", "fts", "dpx", "iff", "lbm", "ilbm", "heic", "heif", "hif", "dng", "cr2", "cr3", "nef", "nrw", "arw", "pef", "orf","rw2", "raf", "abr", "grd", "svg", "svgz", "aco", "ase", "af", "afdesign", "afphoto", "afpub",];const SVG_EXTS: &[&str] = &["svg", "svgz"];diff --git a/apps/photocraft/src/services.rs b/apps/photocraft/src/services.rsindex d4a3869f3..9bafe574e 100644--- a/apps/photocraft/src/services.rs+++ b/apps/photocraft/src/services.rs@@ -21,7 +21,8 @@ mod recovery_tests;/// (.kys), which go to the preset libraries and Edit › Keyboard Shortcuts.const OPEN_EXTS: &[&str] = &["pcraft", "pdn", "ora", "kra", "krz", "psd", "psb", "psdt", "png", "jpg", "jpeg", "tif", "tiff", "webp", "gif", "bmp", "tga", "ico", "qoi", "exr", "hdr",- "pbm", "pgm", "ppm", "pam", "pfm", "pcx", "dds", "xpm", "fits", "fit", "fts", "dpx", "heic", "heif", "hif", "dng", "cr2", "cr3", "nef", "nrw", "arw",+ "pbm", "pgm", "ppm", "pam", "pfm", "pcx", "dds", "xpm", "fits", "fit", "fts", "dpx", "iff", "lbm", "ilbm", "heic", "heif", "hif", "dng", "cr2", "cr3", "nef", "nrw",+ "arw","pef", "orf", "rw2", "raf", "abr", "grd", "svg", "svgz", "aco", "ase", "kys", "af", "afdesign", "afphoto", "afpub",];const SVG_EXTS: &[&str] = &["svg", "svgz"];diff --git a/crates/codecs/README.md b/crates/codecs/README.mdindex 7486d4650..04e3209fb 100644--- a/crates/codecs/README.md+++ b/crates/codecs/README.md@@ -47,6 +47,7 @@ let out = encode(&img, Format::Tiff, &EncodeOptions::default())?;| Radiance HDR | yes | yes | F32 | RGB | no | no | no | no | no | no | yes (RGBE) | `image` || FITS | yes | yes | U8, U16, F32 | Gray, RGB | no | no | no | no | no | yes (header cards) | no | built in || DPX | yes | yes | U8, U16 (10/12-bit code values read and written exactly through U16) | Gray, RGB, RGBA | yes | no | no | no | no | DPX header fields only (creator, project, copyright, creation time, transfer, colorimetric, frame position, frame rate, time code) | no | built in |+| Amiga IFF (ILBM/PBM) | yes | **no** | U8 | RGB | no | no | no | no | no | no | n/a | built in || AVIF | **no** | only with feature `avif` | U8 | RGB, RGBA | yes | no | no | no | no | no | yes | `image` + `ravif` || HEIF/HEIC | with feature `heif` | **no** | U8, U16 (10/12-bit decodes to U16) | RGB, RGBA | yes (auxiliary alpha) | yes (`colr` prof) | yes | yes | no | no | n/a | `heic-rs` |@@ -95,6 +96,12 @@ embedded table (and a PNG's transparent entry) so `photocraft-io` can open themOther descriptors, signed or run-length-encoded data and other bit depths return`CodecError::Unsupported` naming the field. Cineon (`.cin`) is not supported.+* **Amiga IFF (read-only).** `FORM ... ILBM` (interleaved) and `FORM ... PBM ` (planar) bitmaps+ from the published IFF/ILBM layout: 1–8 bitplanes decoded through the `CMAP` palette (a grey+ ramp when there is none), masking 0/1/2, and both stored (0) and ByteRun1/PackBits (1)+ compression. Other bit-plane counts or compressions return `CodecError::Unsupported`; a+ malformed chunk length or run errors rather than panicking. There is no IFF writer; save as PNG.+* **Camera raw files** (DNG, CR2, NEF, ARW… which are TIFF-structured) are recognised and refusedwith `CodecError::Unsupported`: they are sensor data, not flat images. `photocraft-raw` decodesand develops them, and `photocraft-io` routes them there.diff --git a/crates/codecs/src/codecs/iff.rs b/crates/codecs/src/codecs/iff.rsnew file mode 100644index 000000000..421d55c89--- /dev/null+++ b/crates/codecs/src/codecs/iff.rs@@ -0,0 +1,287 @@+//! Amiga IFF/ILBM reader (EA "Interchange File Format", "InterLeaved BitMap" and the planar+//! "PBM " variant). Written from the published IFF/ILBM layout: a `FORM` chunk of four-byte+//! chunks (`BMHD` bitmap header, `CMAP` palette, `CAMG` Amiga viewport mode, `BODY` pixel data).+//! Read-only: modern saves should use PNG.+//!+//! Supported: 1–8 bitplanes with a palette (or a grey ramp when there is none), masking 0/1/2,+//! and both stored (0) and ByteRun1/PackBits (1) compression. Anything else is a clear+//! `Unsupported`/`Malformed` error, never a panic.++use crate::error::CodecError;+use crate::format::Format;+use crate::image::{ChannelLayout, Image, SampleType};+use crate::options::Limits;++const F: Format = Format::Iff;++fn bad(msg: impl std::fmt::Display) -> CodecError {+ CodecError::malformed(F, msg)+}++fn unsupported(msg: impl Into<String>) -> CodecError {+ CodecError::unsupported(F, msg)+}++fn be32(b: &[u8], at: usize) -> Option<u32> {+ let s = b.get(at..at.checked_add(4)?)?.try_into().ok()?;+ Some(u32::from_be_bytes(s))+}++fn be16(b: &[u8], at: usize) -> Option<u16> {+ let s = b.get(at..at.checked_add(2)?)?.try_into().ok()?;+ Some(u16::from_be_bytes(s))+}++/// `FORM` + a bitmap type (`ILBM` interleaved, `PBM ` planar) at offset 8.+pub(crate) fn looks_like_iff(b: &[u8]) -> bool {+ b.get(0..4) == Some(b"FORM") && matches!(b.get(8..12), Some(b"ILBM" | b"PBM "))+}++/// The bitmap header fields decoding needs.+struct Header {+ width: u32,+ height: u32,+ planes: u8,+ masking: u8,+ compression: u8,+ /// `ILBM` interleaves a row's planes; `PBM ` stores a whole plane before the next.+ interleaved: bool,+}++/// One four-byte chunk's id and byte range.+struct Chunk<'a> {+ id: [u8; 4],+ data: &'a [u8],+}++/// Walk the `FORM`'s chunks from offset 12 to `end` (the form length), stopping at the first+/// malformed length so a hostile file can't run past the buffer.+fn chunks(b: &[u8]) -> impl Iterator<Item = Chunk<'_>> {+ let end = be32(b, 4).map_or(b.len(), |n| (n as usize).saturating_add(8).min(b.len()));+ let mut pos = 12usize;+ std::iter::from_fn(move || {+ if pos + 8 > end {+ return None;+ }+ let id = b.get(pos..pos + 4)?.try_into().ok()?;+ let len = be32(b, pos + 4)? as usize;+ let start = pos + 8;+ let data = b.get(start..start.checked_add(len)?)?;+ // Chunks are padded to an even length.+ pos = start.checked_add(len)?.checked_add(len & 1)?;+ Some(Chunk { id, data })+ })+}++fn parse_header(b: &[u8], interleaved: bool) -> Result<Header, CodecError> {+ let bmhd = chunks(b).find(|c| &c.id == b"BMHD").ok_or_else(|| bad("no BMHD chunk"))?;+ let d = bmhd.data;+ if d.len() < 20 {+ return Err(bad("BMHD chunk is too short"));+ }+ let width = u32::from(be16(d, 0).ok_or_else(|| bad("BMHD width"))?);+ let height = u32::from(be16(d, 2).ok_or_else(|| bad("BMHD height"))?);+ let planes = *d.get(8).ok_or_else(|| bad("BMHD planes"))?;+ let masking = *d.get(9).ok_or_else(|| bad("BMHD masking"))?;+ let compression = *d.get(10).ok_or_else(|| bad("BMHD compression"))?;+ if width == 0 || height == 0 {+ return Err(bad("zero-sized bitmap"));+ }+ if !(1..=8).contains(&planes) {+ return Err(unsupported(format!("{planes} bitplanes (1–8, with a palette)")));+ }+ if masking > 2 {+ return Err(unsupported(format!("masking {masking}")));+ }+ if compression > 1 {+ return Err(unsupported(format!("compression {compression} (only stored and ByteRun1)")));+ }+ Ok(Header { width, height, planes, masking, compression, interleaved })+}++/// ByteRun1 / PackBits decode of one plane row into `out`; returns the bytes consumed. A `0x80`+/// control byte is a no-op, as the layout specifies.+fn unpack_byte_run1(src: &[u8], out: &mut [u8]) -> Result<usize, CodecError> {+ let (mut i, mut o) = (0usize, 0usize);+ while o < out.len() {+ let n = *src.get(i).ok_or_else(|| bad("truncated ByteRun1 data"))? as i8;+ i += 1;+ if n >= 0 {+ let count = n as usize + 1;+ let lit = src.get(i..i.checked_add(count).ok_or_else(|| bad("ByteRun1 overflow"))?).ok_or_else(|| bad("truncated ByteRun1 run"))?;+ if count > out.len() - o {+ return Err(bad("ByteRun1 run crosses the plane row"));+ }+ out[o..o + count].copy_from_slice(lit);+ i += count;+ o += count;+ } else if n != -128 {+ let count = (1 - n as i32) as usize;+ let value = *src.get(i).ok_or_else(|| bad("truncated ByteRun1 repeat"))?;+ i += 1;+ if count > out.len() - o {+ return Err(bad("ByteRun1 repeat crosses the plane row"));+ }+ out[o..o + count].fill(value);+ o += count;+ }+ }+ Ok(i)+}++pub(crate) fn decode(b: &[u8], limits: &Limits) -> Result<Image, CodecError> {+ if !looks_like_iff(b) {+ return Err(bad("not an IFF/ILBM file (no FORM ... ILBM)"));+ }+ let interleaved = b.get(8..12) == Some(b"ILBM");+ let h = parse_header(b, interleaved)?;+ limits.check(h.width, h.height, ChannelLayout::Rgb, SampleType::U8)?;++ // Palette: three bytes per colour; missing entries read as black.+ let cmap = chunks(b).find(|c| &c.id == b"CMAP").map(|c| c.data);+ let colors = 1usize << h.planes;+ let palette = |idx: usize| -> [u8; 3] {+ cmap.and_then(|p| p.get(idx * 3..idx * 3 + 3)).map(|c| [c[0], c[1], c[2]]).unwrap_or({+ // No palette: a grey ramp across the index range.+ let v = ((idx as u32 * 255) / (colors as u32 - 1).max(1)) as u8;+ [v, v, v]+ })+ };++ let body = chunks(b).find(|c| &c.id == b"BODY").map(|c| c.data).ok_or_else(|| bad("no BODY chunk"))?;+ let (w, hh) = (h.width as usize, h.height as usize);+ // Each plane row is stored as a whole number of 16-bit words.+ let plane_row = w.div_ceil(16) * 2;+ // A masking type 1 bitmap carries one extra (mask) plane per row.+ let rows_planes: usize = if h.masking == 1 { usize::from(h.planes) + 1 } else { usize::from(h.planes) };++ // Decode every stored plane row up front, then recombine.+ let total_rows = hh.checked_mul(rows_planes).ok_or_else(|| CodecError::LimitExceeded("bitmap too large".into()))?;+ let total_bytes = total_rows.checked_mul(plane_row).ok_or_else(|| CodecError::LimitExceeded("bitmap too large".into()))?;+ let mut stored = vec![0u8; total_bytes];+ let mut cursor = 0usize;+ for row in stored.chunks_mut(plane_row.max(1)).take(total_rows) {+ match h.compression {+ 0 => {+ let src = body.get(cursor..cursor.checked_add(plane_row).ok_or_else(|| bad("BODY overflow"))?).ok_or_else(|| bad("truncated BODY data"))?;+ let n = row.len().min(src.len());+ row[..n].copy_from_slice(&src[..n]);+ cursor += plane_row;+ }+ _ => {+ let tail = body.get(cursor..).ok_or_else(|| bad("truncated BODY data"))?;+ cursor += unpack_byte_run1(tail, row)?;+ }+ }+ }++ let mut out = Vec::new();+ out.try_reserve_exact(w.saturating_mul(hh).saturating_mul(3)).map_err(|_| CodecError::LimitExceeded("cannot allocate the image".into()))?;+ let planes = usize::from(h.planes);+ for y in 0..hh {+ for x in 0..w {+ let index = if h.interleaved {+ // Row-major, interleaved: row y, plane p sits at (y * rows_planes + p).+ (0..planes).filter(|&p| bit_at(&stored, (y * rows_planes + p) * plane_row, x)).fold(0usize, |acc, p| acc | (1 << p))+ } else {+ // Planar: plane p's rows come first, then the next plane.+ (0..planes).filter(|&p| bit_at(&stored, (p * hh + y) * plane_row, x)).fold(0usize, |acc, p| acc | (1 << p))+ };+ let c = palette(index);+ out.extend_from_slice(&c);+ }+ }+ Image::from_u8(h.width, h.height, ChannelLayout::Rgb, out)+}++/// The bit for pixel `x` of a stored plane row at `base` (bits run MSB-first).+fn bit_at(stored: &[u8], base: usize, x: usize) -> bool {+ stored.get(base + x / 8).is_some_and(|byte| byte & (0x80 >> (x % 8)) != 0)+}++#[cfg(test)]+mod tests {+ use super::*;++ /// A `FORM ILBM` with a `BMHD`, `CMAP` and `BODY`. `planes` plane rows per row,+ /// `compression` 0 (stored) or 1 (ByteRun1), MSB-first.+ fn ilbm(w: u16, h: u16, planes: u8, palette: &[[u8; 3]], compression: u8, body: &[u8]) -> Vec<u8> {+ let mut b = b"FORM".to_vec();+ b.extend_from_slice(&0u32.to_be_bytes()); // patched below+ b.extend_from_slice(b"ILBM");+ // BMHD (20 bytes)+ b.extend_from_slice(b"BMHD");+ b.extend_from_slice(&20u32.to_be_bytes());+ b.extend_from_slice(&w.to_be_bytes());+ b.extend_from_slice(&h.to_be_bytes());+ b.extend_from_slice(&[0, 0, 0, 0]); // x/y origin+ b.push(planes);+ b.push(0); // masking+ b.push(compression);+ b.push(0); // pad+ b.extend_from_slice(&[0, 0]); // transparent colour+ b.extend_from_slice(&[1, 1]); // aspect+ b.extend_from_slice(&[0, 0, 0, 0]); // page size+ // CMAP+ b.extend_from_slice(b"CMAP");+ b.extend_from_slice(&((palette.len() * 3) as u32).to_be_bytes());+ for c in palette {+ b.extend_from_slice(c);+ }+ // BODY+ b.extend_from_slice(b"BODY");+ b.extend_from_slice(&(body.len() as u32).to_be_bytes());+ b.extend_from_slice(body);+ if body.len() % 2 == 1 {+ b.push(0);+ }+ let size = (b.len() - 8) as u32;+ b[4..8].copy_from_slice(&size.to_be_bytes());+ b+ }++ #[test]+ fn reads_a_stored_two_plane_bitmap() {+ // 2×1, 2 planes: pixel 0 index 0 (plane bits 0,0), pixel 1 index 3 (bits 1,1).+ // Plane 0 = 0b0100_0000, plane 1 = 0b0100_0000, each padded to 2 bytes.+ let body = [0b0100_0000, 0, 0b0100_0000, 0];+ let pal = [[10, 20, 30], [40, 50, 60], [70, 80, 90], [100, 110, 120]];+ let b = ilbm(2, 1, 2, &pal, 0, &body);+ assert!(looks_like_iff(&b));+ let img = decode(&b, &Limits::default()).unwrap();+ assert_eq!((img.width(), img.height(), img.layout()), (2, 1, ChannelLayout::Rgb));+ assert_eq!(img.data(), &[10, 20, 30, 100, 110, 120]);+ }++ #[test]+ fn reads_byte_run1_compressed_rows() {+ // Same image, ByteRun1: literal run of two bytes (0x01) then the two plane bytes each row.+ let body = [0x01, 0b0100_0000, 0, 0x01, 0b0100_0000, 0];+ let pal = [[1, 2, 3], [4, 5, 6], [7, 8, 9], [250, 251, 252]];+ let b = ilbm(2, 1, 2, &pal, 1, &body);+ let img = decode(&b, &Limits::default()).unwrap();+ assert_eq!(img.data(), &[1, 2, 3, 250, 251, 252]);+ }++ #[test]+ fn no_palette_falls_back_to_a_grey_ramp() {+ // 2×1, 1 plane, no CMAP: indices 0 and 1 → black and white.+ let body = [0b0100_0000, 0];+ let b = ilbm(2, 1, 1, &[], 0, &body);+ let img = decode(&b, &Limits::default()).unwrap();+ assert_eq!(img.data(), &[0, 0, 0, 255, 255, 255]);+ }++ #[test]+ fn hostile_input_errors_not_panics() {+ // Truncations of a valid file never panic.+ let body = [0b0100_0000, 0, 0b0100_0000, 0];+ let full = ilbm(2, 1, 2, &[[1, 2, 3], [4, 5, 6], [7, 8, 9], [10, 11, 12]], 0, &body);+ for cut in [0, 4, 8, 12, 40, full.len() - 1] {+ assert!(decode(&full[..cut.min(full.len())], &Limits::default()).is_err(), "cut {cut}");+ }+ // Too many planes is unsupported.+ let bad = ilbm(1, 1, 9, &[], 0, &[0, 0]);+ assert!(matches!(decode(&bad, &Limits::default()), Err(CodecError::Unsupported { .. })));+ }+}diff --git a/crates/codecs/src/codecs/mod.rs b/crates/codecs/src/codecs/mod.rsindex afb7f9679..1b1683f4a 100644--- a/crates/codecs/src/codecs/mod.rs+++ b/crates/codecs/src/codecs/mod.rs@@ -6,6 +6,7 @@ pub(crate) mod exr_cryptomatte;pub(crate) mod fits;pub(crate) mod gif_frames;pub(crate) mod heif;+pub(crate) mod iff;pub(crate) mod jpeg;pub(crate) mod pcx;pub(crate) mod png;diff --git a/crates/codecs/src/format.rs b/crates/codecs/src/format.rsindex d3730c08f..e5fd1e119 100644--- a/crates/codecs/src/format.rs+++ b/crates/codecs/src/format.rs@@ -33,6 +33,8 @@ pub enum Format {Fits,/// DPX (SMPTE 268M Digital Picture Exchange): luma, RGB or RGBA film and video frames.Dpx,+ /// Amiga IFF/ILBM (`FORM ... ILBM`): planar bitplanes with a palette, read-only.+ Iff,}/// What a format can hold **and** what this crate reads/writes for it.@@ -65,6 +67,7 @@ pub struct FormatCaps {/// The test-suite asserts that every other enabled format is read+write.pub const ASYMMETRIC_EXCEPTIONS: &[(Format, &str)] = &[(Format::Xpm, "XPM is a legacy Unix icon interchange format. Reading existing XPM icons is supported; writing modern image assets should use PNG instead."),+ (Format::Iff, "Amiga IFF/ILBM is supported for opening legacy Amiga artwork; this crate has no IFF writer, so save as PNG instead."),(Format::Pcx,"PCX is supported for opening legacy paint and clipart assets. New files should use PNG; writing obsolete indexed and planar variants is intentionally not provided.",@@ -95,7 +98,7 @@ const ALL_LAYOUTS: &[ChannelLayout] = &[L::Gray, L::GrayA, L::Rgb, L::Rgba, L::Cimpl Format {/// Every format known to the crate (enabled or not).- pub const ALL: [Format; 19] = [+ pub const ALL: [Format; 20] = [Format::Png,Format::Jpeg,Format::Tiff,@@ -115,6 +118,7 @@ impl Format {Format::Heif,Format::Fits,Format::Dpx,+ Format::Iff,];pub fn caps(self) -> FormatCaps {@@ -148,6 +152,7 @@ impl Format {Format::Heif => "HEIF",Format::Fits => "FITS",Format::Dpx => "DPX",+ Format::Iff => "Amiga IFF",}}@@ -174,6 +179,7 @@ impl Format {Format::Heif => &["heic", "heif", "hif"],Format::Fits => &["fits", "fit", "fts"],Format::Dpx => &["dpx"],+ Format::Iff => &["iff", "lbm", "ilbm"],}}@@ -198,6 +204,7 @@ impl Format {Format::Heif => "image/heif",Format::Fits => "image/fits",Format::Dpx => "image/x-dpx",+ Format::Iff => "image/x-iff",}}@@ -253,6 +260,7 @@ pub fn caps(format: Format) -> FormatCaps {Format::Fits => FormatCaps { depths: &[S::U8, S::U16, S::F32], layouts: &[L::Gray, L::Rgb], alpha: false, text: true, ..base },// `text`: the DPX header fields only (see `fidelity_warnings_with`).Format::Dpx => FormatCaps { depths: &[S::U8, S::U16], layouts: &[L::Gray, L::Rgb, L::Rgba], text: true, ..base },+ Format::Iff => FormatCaps { read: true, write: false, depths: &[S::U8], layouts: &[L::Rgb], alpha: false, ..base },}}@@ -307,6 +315,9 @@ pub fn detect(bytes: &[u8]) -> Option<Format> {if b.starts_with(b"SDPX") || b.starts_with(b"XPDS") {return Some(Format::Dpx);}+ if crate::codecs::iff::looks_like_iff(b) {+ return Some(Format::Iff);+ }if b.starts_with(b"SIMPLE =") {return Some(Format::Fits);}diff --git a/crates/codecs/src/lib.rs b/crates/codecs/src/lib.rsindex 438e1857e..88cc17167 100644--- a/crates/codecs/src/lib.rs+++ b/crates/codecs/src/lib.rs@@ -43,7 +43,7 @@ pub use crate::resolution::{exif_resolution, export_exif, export_xmp, photoshop_pub use crate::source_settings::{WebpEncoding, jpeg_quality, webp_encoding};pub use half::f16;-use crate::codecs::{dds, dpx, exr, fits, heif, jpeg, pcx, png, pnm, tiff, via_image, webp, xpm};+use crate::codecs::{dds, dpx, exr, fits, heif, iff, jpeg, pcx, png, pnm, tiff, via_image, webp, xpm};/// Detect the format and decode with default [`Limits`].pub fn decode(bytes: &[u8]) -> Result<Image, CodecError> {@@ -79,6 +79,7 @@ pub fn decode_as_with(format: Format, bytes: &[u8], opts: &DecodeOptions) -> ResFormat::Dds => dds::decode(bytes, l),Format::Fits => fits::decode(bytes, l),Format::Dpx => dpx::decode(bytes, l),+ Format::Iff => iff::decode(bytes, l),Format::OpenExr => exr::decode(bytes, l),Format::Heif => heif::decode(bytes, l, opts.keep_orientation),Format::Gif | Format::Bmp | Format::Tga | Format::Ico | Format::Qoi | Format::Hdr | Format::Avif => via_image::decode(format, bytes, l),@@ -231,6 +232,7 @@ pub fn encode(image: &Image, format: Format, opts: &EncodeOptions) -> Result<VecFormat::Dds => Err(CodecError::unsupported(format, "DDS is import-only; save as PNG instead")),Format::Fits => fits::encode(image, plan, opts),Format::Dpx => dpx::encode(image, plan, opts),+ Format::Iff => Err(CodecError::unsupported(format, "IFF/ILBM is import-only; save as PNG instead")),Format::OpenExr => exr::encode(image, plan, opts),Format::Heif => Err(CodecError::unsupported(format, "encoding is not available in this build")),Format::Gif | Format::Bmp | Format::Tga | Format::Ico | Format::Qoi | Format::Hdr | Format::Avif => via_image::encode(format, image, plan, opts),diff --git a/crates/codecs/tests/detect_caps.rs b/crates/codecs/tests/detect_caps.rsindex 22bf227eb..12bfdc4c3 100644--- a/crates/codecs/tests/detect_caps.rs+++ b/crates/codecs/tests/detect_caps.rs@@ -187,6 +187,19 @@ fn detect_magic_hdr() {assert_eq!(detect(b"#?RGBE\n"), Some(Format::Hdr));}#[test]+fn detect_magic_iff() {+ // FORM + a four-byte length + the bitmap type.+ assert_eq!(detect(b"FORM\0\0\0\x14ILBM"), Some(Format::Iff));+ assert_eq!(detect(b"FORM\0\0\0\x14PBM "), Some(Format::Iff));+ assert_eq!(from_extension("art.LBM"), Some(Format::Iff));+ assert_eq!(from_extension("art.ilbm"), Some(Format::Iff));+ assert!(caps(Format::Iff).read && !caps(Format::Iff).write, "IFF is read-only");+ assert!(ASYMMETRIC_EXCEPTIONS.iter().any(|(f, _)| *f == Format::Iff));+ // A bare FORM without a bitmap type is not IFF.+ assert_eq!(detect(b"FORM\0\0\0\x14AIFF"), None);+ assert!(decode_as(Format::Iff, b"FORM\0\0\0\x14ILBM").is_err());+}+#[test]fn detect_magic_avif() {assert_eq!(detect(b"\0\0\0\x1cftypavif\0\0\0\0avifmif1miaf"), Some(Format::Avif));assert_eq!(detect(b"\0\0\0\x1cftypavis\0\0\0\0avismsf1miaf"), Some(Format::Avif));diff --git a/docs/file-format-parity.md b/docs/file-format-parity.mdindex cb2ca13ac..d6681d422 100644--- a/docs/file-format-parity.md+++ b/docs/file-format-parity.md@@ -47,7 +47,7 @@ XL are missing (gap G10). Remaining: 300–500 h including PSD fidelity.| DICOM | R/W | no | no | || PCX | R/W | no | no | || Pixar | R/W | no | no | |-| Amiga IFF | R/W | no | no | |+| Amiga IFF | R/W | yes | no | Read-only: 1–8 planes with CMAP, stored and ByteRun1 || Wireless Bitmap | R/W | no | no | || MPO / JPS (stereo) | R/W | no | no | || PICT | R | no | no | Legacy |diff --git a/docs/gaps.md b/docs/gaps.mdindex 25a286aab..949eb6832 100644--- a/docs/gaps.md+++ b/docs/gaps.md@@ -1,6 +1,6 @@# Where PhotoCraft falls short of Photoshop-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed) · **Target:** Adobe Photoshop 2026+> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G7: Field Blur's on-canvas pins, #3373; G4: Hue Jitter amount track, #3825 partial; G4: minimum field interaction, #3825 partial; G1: CMYK Invert, Posterize and Threshold on the inks, 16-bit Lab Invert; Photoshop-oracle floor 145/258; G11: `.atn` import maps 112 events: Select and Mask, Filter Gallery Spatter, Ripple, Crystallize, Pattern Fill layers, mask targeting, Step Backward, nudges in points, Bitmap mode; G5: Free Transform H/V skew fields; G9: toolbar tool shortcut editing; refreshed against main: G2, G5, G7, G9, G10, G13, G14, G17 items that landed; G10: DPX read and write, #1049, and Amiga IFF read; G4: checkbox-only Brush Settings rows; G11: Load/Save Actions `.atn` landed, AUTO-219-2 partial; G5: hold-a-key spring-loaded tools landed, #2672; G1: #2465 fixed) · **Target:** Adobe Photoshop 2026Every known shortfall against Photoshop 2026 (27.11.0), one entry each, ranked by user impacton the way to beta. This is the work list agents pick from: take the highest-ranked entry that@@ -220,10 +220,13 @@ what an agent can't finish alone.### G10. Missing and partial file formats- **Missing:** JPEG Options dialog (FILE-215-19), Photoshop PDF read and write and multi-page PDF(FILE-215-10, #2541), AVIF read (#463) and default-build AVIF write, JPEG XL, JPEG 2000 (#1047),- Cineon (DPX landed, #1049), DICOM, EPS/DCS, PCX, Pixar, IFF, WBMP, MPO/JPS, PICT, Scitex CT, Photoshop- Raw; layered TIFF extra alpha channels (FILE-215-7); spot plates (FILE-215-17); .atn, .asl,- .shc, .csh presets (FILE-215-15); C2PA (#1050).+ Cineon (DPX landed, #1049), DICOM, EPS/DCS, PCX, Pixar, IFF write (read landed), WBMP, MPO/JPS,+ PICT, Scitex CT, Photoshop Raw; layered TIFF extra alpha channels (FILE-215-7); spot plates+ (FILE-215-17); .atn, .asl, .shc, .csh presets (FILE-215-15); C2PA (#1050).- **Detail:** [`file-format-parity.md`](file-format-parity.md).+- **Progress (2026-10-13):** Amiga IFF/ILBM (`FORM ... ILBM`/`PBM `) 1–8-plane paletted bitmaps+ open read-only, stored or ByteRun1-compressed (`crates/codecs/src/codecs/iff.rs`); writing is+ still open.- **Estimate:** 120–220 h.## Hardware gaps@@ -263,6 +266,7 @@ what an agent can't finish alone.| Date | Change | Summary ||---|---|---|+| 2026-10-13 | minor | G10: Amiga IFF/ILBM read landed (1–8 planes, CMAP, stored and ByteRun1); IFF write remains open || 2026-10-13 | minor | G4: Hue Jitter amount-track appearance (#3825, partial); no readiness percentage or estimate changed || 2026-10-13 | minor | G4: minimum inputs in Shape Dynamics and Transfer follow their Control (#3825, partial); no readiness percentage or estimate changed || 2026-10-12 | minor | G5: Free Transform options bar H/V skew fields done |