mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-27 13:17:41 +00:00
image-codecs: borrow the ICC profile and EXIF in the PNG header
The PNG writer copied the caller's ICC profile, and the exported EXIF, into new buffers before writing the header. Each tagged save allocated a second profile-sized buffer that could abort the process when memory ran short. The header now borrows the profile, and borrows the EXIF whenever export_exif returns it unchanged.
This commit is contained in:
@@ -1360,12 +1360,12 @@ fn start<W: Write>(
|
||||
if opts.embed_icc
|
||||
&& let Some(icc) = icc
|
||||
{
|
||||
info.icc_profile = Some(icc.clone().into());
|
||||
info.icc_profile = Some(std::borrow::Cow::Borrowed(icc.as_slice()));
|
||||
}
|
||||
if opts.embed_metadata {
|
||||
if let Some(exif) = &meta.exif {
|
||||
// The pixels are written as they are shown: never let a viewer rotate them again.
|
||||
info.exif_metadata = Some(crate::resolution::export_exif(exif, meta.dpi).into_owned().into());
|
||||
info.exif_metadata = Some(crate::resolution::export_exif(exif, meta.dpi));
|
||||
}
|
||||
if let Some((x, y)) = meta.dpi
|
||||
&& x > 0.0
|
||||
|
||||
Reference in New Issue
Block a user