PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Merge remote-tracking branch 'origin/main' into feat/iff-read
Vikram Bhaskaran2af160d65fb3
diff --cc apps/photocraft-web/src/web.rsindex 1a34f0b06,eb350d17e..90e080d2a--- a/apps/photocraft-web/src/web.rs+++ b/apps/photocraft-web/src/web.rs@@@ -18,8 -18,8 +18,8 @@@ type Inbox = Arc<Mutex<Vec<(String, Vec/// 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", "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",- "pbm", "pgm", "ppm", "pam", "pfm", "dds", "fits", "fit", "fts", "dpx", "cin", "heic", "heif", "hif", "dng", "cr2", "cr3", "nef", "nrw", "arw", "pef",++ "pbm", "pgm", "ppm", "pam", "pfm", "dds", "fits", "fit", "fts", "dpx", "cin", "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"];const CANVAS_ID: &str = "photocraft_canvas";diff --cc apps/photocraft/src/services.rsindex 5920d2feb,9de1c475e..d44748cdb--- a/apps/photocraft/src/services.rs+++ b/apps/photocraft/src/services.rs@@@ -21,9 -21,8 +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", "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",- "pbm", "pgm", "ppm", "pam", "pfm", "pcx", "dds", "xpm", "fits", "fit", "fts", "dpx", "cin", "heic", "heif", "hif", "dng", "cr2", "cr3", "nef", "nrw",++ "pbm", "pgm", "ppm", "pam", "pfm", "pcx", "dds", "xpm", "fits", "fit", "fts", "dpx", "cin", "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 --cc crates/codecs/README.mdindex 04e3209fb,d4f709489..958d71d88--- a/crates/codecs/README.md+++ b/crates/codecs/README.md@@@ -47,7 -47,7 +47,8 @@@ let out = encode(&img, Format::Tiff, &E| 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 |+ | Cineon | yes | **no** | U16 (10-bit code values) | Gray, RGB | no | no | no | no | no | no | n/a | 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` |@@@ -94,14 -94,16 +95,22 @@@ embedded table (and a PNG's transparenbig-endian, one unencoded element, at `EncodeOptions::dpx_bits` (8/10/12/16; by default 8 forU8 and 16 otherwise), packing 1 for 10 and 12 bits; gray with alpha is written as luma.Other descriptors, signed or run-length-encoded data and other bit depths return- `CodecError::Unsupported` naming the field. Cineon (`.cin`) is not supported.+ `CodecError::Unsupported` naming the field.++ * **Cineon (read-only).** Kodak's 10-bit logarithmic film-scan format (the one DPX grew from),+ read from the same Kodak header family: the generic 1024-byte header, big-endian, one (Gray)+ or three (RGB) channels, three 10-bit samples packed into each 32-bit word, lines on a word+ boundary. The 10-bit code values open as U16 `round(c × 65535 / 1023)`; the file's black/white+ reference points are a log-conversion choice and are not applied. A depth other than 10 bits or+ a channel count other than 1/3 returns `CodecError::Unsupported`; truncation errors rather than+ panicking. There is no Cineon writer (`ASYMMETRIC_EXCEPTIONS`); save as DPX, TIFF or EXR.+* **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 --cc crates/codecs/src/format.rsindex e5fd1e119,fa2e1e6cb..771d7a64e--- a/crates/codecs/src/format.rs+++ b/crates/codecs/src/format.rs@@@ -33,8 -33,8 +33,10 @@@ pub enum FormatFits,/// DPX (SMPTE 268M Digital Picture Exchange): luma, RGB or RGBA film and video frames.Dpx,+ /// Kodak Cineon (`.cin`, the 10-bit film-scan format DPX grew from): read-only.+ Cineon,+ /// 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.@@@ -98,7 -104,7 +107,7 @@@ const TIFF_LAYOUTS: &[ChannelLayout] =impl Format {/// Every format known to the crate (enabled or not).-- pub const ALL: [Format; 20] = [++ pub const ALL: [Format; 21] = [Format::Png,Format::Jpeg,Format::Tiff,@@@ -118,7 -124,7 +127,8 @@@Format::Heif,Format::Fits,Format::Dpx,+ Format::Cineon,+ Format::Iff,];pub fn caps(self) -> FormatCaps {@@@ -152,7 -158,7 +162,8 @@@Format::Heif => "HEIF",Format::Fits => "FITS",Format::Dpx => "DPX",+ Format::Cineon => "Cineon",+ Format::Iff => "Amiga IFF",}}@@@ -179,7 -185,7 +190,8 @@@Format::Heif => &["heic", "heif", "hif"],Format::Fits => &["fits", "fit", "fts"],Format::Dpx => &["dpx"],+ Format::Cineon => &["cin"],+ Format::Iff => &["iff", "lbm", "ilbm"],}}@@@ -204,7 -210,7 +216,8 @@@Format::Heif => "image/heif",Format::Fits => "image/fits",Format::Dpx => "image/x-dpx",+ Format::Cineon => "image/x-cin",+ Format::Iff => "image/x-iff",}}@@@ -260,7 -266,7 +273,8 @@@ pub fn caps(format: Format) -> FormatCaFormat::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::Cineon => FormatCaps { read: true, write: false, depths: &[S::U16], layouts: &[L::Gray, L::Rgb], alpha: false, ..base },+ Format::Iff => FormatCaps { read: true, write: false, depths: &[S::U8], layouts: &[L::Rgb], alpha: false, ..base },}}@@@ -315,9 -321,9 +329,13 @@@ pub fn detect(bytes: &[u8]) -> Option<Fif b.starts_with(b"SDPX") || b.starts_with(b"XPDS") {return Some(Format::Dpx);}+ if crate::codecs::dpx::is_cineon(b) {+ return Some(Format::Cineon);+ }+ if crate::codecs::iff::looks_like_iff(b) {+ return Some(Format::Iff);+ }++ }if b.starts_with(b"SIMPLE =") {return Some(Format::Fits);}diff --cc crates/codecs/src/lib.rsindex 7aa62178a,86611599d..ad54ca88d--- a/crates/codecs/src/lib.rs+++ b/crates/codecs/src/lib.rs@@@ -79,7 -80,7 +80,8 @@@ pub fn decode_as_with(format: Format, bFormat::Dds => dds::decode(bytes, l),Format::Fits => fits::decode(bytes, l),Format::Dpx => dpx::decode(bytes, l),+ Format::Cineon => dpx::decode_cineon(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),@@@ -253,7 -255,7 +256,8 @@@ pub fn encode(image: &Image, format: FoFormat::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::Cineon => Err(CodecError::unsupported(format, "Cineon is import-only; save as DPX, TIFF or EXR instead")),+ 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 --cc crates/codecs/tests/detect_caps.rsindex 12bfdc4c3,f2191e05f..c0cd569e3--- a/crates/codecs/tests/detect_caps.rs+++ b/crates/codecs/tests/detect_caps.rs@@@ -186,19 -186,17 +186,31 @@@ fn detect_magic_hdr()assert_eq!(detect(b"#?RADIANCE\n"), Some(Format::Hdr));assert_eq!(detect(b"#?RGBE\n"), Some(Format::Hdr));}+ #[test]+ fn detect_magic_cineon() {+ let mut b = vec![0u8; 208];+ b[0..4].copy_from_slice(&[0x80, 0x2A, 0x5F, 0xD7]);+ assert_eq!(detect(&b), Some(Format::Cineon));+ assert_eq!(from_extension("scan.CIN"), Some(Format::Cineon));+ assert!(caps(Format::Cineon).read && !caps(Format::Cineon).write, "Cineon is read-only");+ assert!(ASYMMETRIC_EXCEPTIONS.iter().any(|(f, _)| *f == Format::Cineon));+ // A bare magic is an error, never a panic.+ assert!(decode_as(Format::Cineon, &b).is_err());+ }+++#[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));diff --cc docs/gaps.mdindex be62e602b,faf0884c8..29dfdd31a--- a/docs/gaps.md+++ b/docs/gaps.md@@@ -1,6 -1,6 +1,6 @@@# Where PhotoCraft falls short of Photoshop- > **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026-> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **Target:** Adobe Photoshop 2026++> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-10-13 · **Change:** minor (G1: smart filter masks show on PSD open, Photoshop-oracle floor 188/258; G10: DPX read and write, #1049, Cineon and Amiga IFF read; G1: CMYK Hue/Saturation and Color Balance keep the black ink; G1: CMYK Posterize on the stored values, psd-tools oracle floor 242/309; G1: CMYK adjustment layers composite on the document's inks, Photoshop-oracle floor 165/258; G1: CMYK Brightness/Contrast on the inks, CMYK Threshold's luma; G1: modern Brightness/Contrast's brightness curve matches Photoshop, Photoshop-oracle floor 151/258; G1: Lab documents composite on their stored L, a, b, Photoshop-oracle floor 152/258; G1: Levels on whole levels at every step, Photoshop-oracle floor 146/258, psd-tools 238/309; G1: 32-bit Brightness/Contrast legacy, Channel Mixer, Photo Filter and Black & White tint unclipped as in Photoshop, Photoshop-oracle floor 149/258; G1: mask feathers blur with their exact variance, psd-tools oracle floor 240/309; G1: Threshold splits on Photoshop's luminosity, psd-tools oracle floor 241/309; G1: pass-through clipping base with an adjustment renders isolated, psd-tools oracle floor 240/309; G1: 16-bit Posterize as Photoshop bins it, psd-tools oracle floor 241/309; G1: Gradient Map driven by the W3C luminosity, Photoshop-oracle floor 147/258; 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; stale missing-tool rows corrected: Color Replacement, Red Eye and Add/Delete Anchor Point are live tools, so only Art History Brush is missing; no estimate changed) · **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@@@ -218,15 -222,15 +222,18 @@@ what an agent can't finish alone## File-format gaps### 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 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).+ - **Missing:** JPEG Options dialog (FILE-215-19), Photoshop PDF read and its vector/text/multi-page+ write (FILE-215-10, #2541; a single flattened page now saves via Save As / Save a Copy / CLI,+ 2026-10-11, #3401), AVIF read (#463) and default-build AVIF write, JPEG XL, JPEG 2000 (#1047),- Cineon write (read landed), DICOM, EPS/DCS, Pixar, IFF, WBMP, MPO/JPS, PICT, Scitex CT, Photoshop++ Cineon write (read landed), DICOM, EPS/DCS, 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):** Cineon (`.cin`) 10-bit gray/RGB frames open read-only, sharing the+ DPX header/unpacking (`crates/codecs/src/codecs/dpx.rs`); writing is still open.+- **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