Skip to content

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

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

Vikram Bhaskaranc0eb60dc841b
diff --cc crates/io/src/lib.rs
index 2fdde88f3,f604b8c17..89dc11d70
--- a/crates/io/src/lib.rs
+++ b/crates/io/src/lib.rs
@@@ -303,12 -305,25 +332,13 @@@ fn import_psd(name: &str, bytes: &[u8]
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) {
- return Ok(ImportResult { document: photocraft_format::load_from_bytes(bytes)?, warnings: Vec::new(), source_read_only: false, preview_only: false });
+ let document = photocraft_format::load_from_bytes(bytes)?;
+ return Ok(ImportResult { warnings: open_warnings(&document), document, source_read_only: false, preview_only: false });
}
+ // Magic first: an Affinity file renamed .psd is still Affinity (#5258 corpus
+ // preview_never_saves_back_to_its_native_or_renamed_source).
if is_psd(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_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);
- return Ok(ImportResult { document, warnings, source_read_only: false, preview_only: false });
+ return import_psd(name, bytes, ctl);
}
if affinity::is_affinity(bytes) || affinity::has_extension(name) {
return affinity::import(name, bytes);