Skip to content

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

Merge remote-tracking branch 'origin/main' into fix/5258-psd-open

Vikram Bhaskaran6b7f08fcd697
diff --cc crates/io/src/lib.rs
index 7050cffd7,a620ddcf3..9544af7bf
--- a/crates/io/src/lib.rs
+++ b/crates/io/src/lib.rs
@@@ -276,19 -268,6 +277,20 @@@ pub fn import_with_svg_group_depth_and_
Ok(r)
}
+fn import_psd(name: &str, bytes: &[u8], ctl: &photocraft_raster::Interrupt) -> Result<ImportResult, IoError> {
- let file = PsdFile::from_bytes(bytes)?;
++ // 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))?;
+ // 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_with(&file, ctl).ok_or(IoError::Cancelled)?;
++ 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) {