PhotoCraft: An open-source, photo editor written by scratch in pure Rust
Integration: merge the new head of #6658, resolve conflicts (#6658)
David Mann1b642e0d64e6
diff --cc crates/io/src/lib.rsindex 809b19e7a,22dabaf6a..77b7d7944--- a/crates/io/src/lib.rs+++ b/crates/io/src/lib.rs@@@ -343,25 -327,8 +343,27 @@@ pub fn import_for_open_with(name: &strOk((result, damaged))}+fn import_psd(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt, damaged: &mut bool) -> Result<ImportResult, IoError> {+ // A merged image the import reads is decoded with the parse: a ZIP one is inflated once.+ let (file, merged) = PsdFile::from_bytes_and_merged_recovering(+ bytes,+ |f| psd_import::check_group_depth(f).is_ok() && psd_import::merged_needed(f),+ psd_import::can_recover_layers,+ )?;+ // Nesting past the document model's cap could never be saved; reject the file with the+ // actionable limit.+ psd_import::check_group_depth(&file)?;+ ctl.check().map_err(|_| IoError::Cancelled)?;+ ctl.progress(0.05);+ let (mut document, warnings, psd_damaged) = psd_import::psd_to_document_decoded_integrity(&file, ctl, merged).ok_or(IoError::Cancelled)?;+ *damaged = psd_damaged;+ document.name = name.to_string();+ text_import::prepare(&mut document);+ Ok(ImportResult { document, warnings, source_read_only: false, preview_only: false })+}++ /// Dispatches format-specific importers and propagates a structured PSD damage+ /// flag alongside the ordinary best-effort import result.fn import_stages(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt, max_group_depth: usize, damaged: &mut bool) -> Result<ImportResult, IoError> {// A declared native extension must reach its loader so malformed bundles retain format errors.if has_extension(name, photocraft_format::EXTENSION) || photocraft_format::is_pcraft(bytes) {@@@ -635,9 -606,10 +637,10 @@@ pub fn merged_composite(file: &PsdFile#[cfg(test)]mod tests {- use super::{import, import_for_open, is_svg_input};+ use super::{import, import_for_open, is_psd_input, is_svg_input};use photocraft_psd::{Compression, Version, testgen};+ /// Verifies a valid PSD remains editable after import.#[test]fn valid_psd_can_still_be_edited() {let bytes = testgen::small(Version::Psd, Compression::Raw).to_bytes().unwrap();