mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
fix(io): warn when the PSD channel limit drops Quick Mask (#115)
This commit is contained in:
1 parent
1863164182
commit
e61bfa60eb
2 files changed
+14
-1
No files matched your search
@@ -628,7 +628,11 @@ pub fn document_to_psd_with(doc: &Document, opts: &PsdExportOptions) -> (PsdFile
|
||||
extra.push(q);
|
||||
Some((cc + usize::from(has_alpha) + extra.len() - 1) as u16)
|
||||
}
|
||||
_ => None,
|
||||
Some(_) => {
|
||||
ex.warnings.push("Quick Mask was dropped because the PSD channel limit was reached".into());
|
||||
None
|
||||
}
|
||||
None => None,
|
||||
};
|
||||
for a in &extra {
|
||||
let s = if a.surface.format() != ex.mask_fmt { a.surface.convert(ex.mask_fmt) } else { a.surface.clone() };
|
||||
|
||||
@@ -41,4 +41,13 @@ fn channel_options_spot_and_quick_mask_roundtrip() {
|
||||
assert_eq!(f2.resources.iter().filter(|r| r.id == 1077).count(), 1);
|
||||
assert_eq!(f2.resources.iter().filter(|r| r.id == 1022).count(), 1);
|
||||
}
|
||||
|
||||
let mut full = Document::with_background("full", Size::new(1, 1), ColorMode::Rgb, SampleType::U8, Color::WHITE);
|
||||
full.channels = (0..53).map(|i| AlphaChannel::new(format!("Alpha {i}"), Surface::new(PixelFormat::GRAY8))).collect();
|
||||
full.quick_mask = Some(AlphaChannel::new("Quick Mask", Surface::new(PixelFormat::GRAY8)));
|
||||
let out = photocraft_io::export(&full, "full.psd", &Default::default()).unwrap();
|
||||
assert!(out.warnings.iter().any(|warning| warning.contains("Quick Mask")), "{:?}", out.warnings);
|
||||
let file = photocraft_psd::PsdFile::from_bytes(&out.bytes).unwrap();
|
||||
assert_eq!(file.header.channels, 56);
|
||||
assert!(file.resources.iter().all(|resource| resource.id != 1022));
|
||||
}
|
||||
Reference in new issue
Block a user