Skip to content

PhotoCraft: An open-source, photo editor written by scratch in pure Rust

Merge origin/main into fix/5258-psd-open

Vikram Bhaskarancf2d819fad1e
diff --cc crates/io/src/lib.rs
index 9544af7bf,3543cd359..2fdde88f3
--- a/crates/io/src/lib.rs
+++ b/crates/io/src/lib.rs
@@@ -277,20 -273,6 +282,24 @@@ pub fn import_with_svg_group_depth_and_
Ok(r)
}
+fn import_psd(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt) -> 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(bytes, |f| psd_import::check_group_depth(f).is_ok() && psd_import::merged_needed(f))?;
++ 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_import::psd_to_document_decoded(&file, ctl, merged).ok_or(IoError::Cancelled)?;
+ document.name = name.to_string();
+ text_import::prepare(&mut document);
+ Ok(ImportResult { document, warnings, source_read_only: false, preview_only: false })
+}
+
fn import_stages(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt, max_group_depth: usize) -> 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) {