Add MemoizeImpure node and cache image base64 in graph (#1595)

* Cache base64 representation of images when converting to graphic group

* Fix build

* Fix build again

* Actually fix it this time

---------

Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
Dennis Kobert
2024-02-03 23:16:03 +01:00
co-authored by Keavon Chambers
parent 8fa46ba63a
commit 349ec5da72
12 changed files with 127 additions and 13 deletions
+7 -2
View File
@@ -446,7 +446,7 @@ async fn imaginate_maybe_fail<'a, P: Pixel, F: Fn(ImaginateStatus)>(
fn image_to_base64<P: Pixel>(image: Image<P>) -> Result<String, Error> {
use base64::prelude::*;
let Image { width, height, data } = image;
let Image { width, height, data, .. } = image;
fn cast_with_f32<S: Pixel, D: image::Pixel<Subpixel = f32>>(data: Vec<S>, width: u32, height: u32) -> Result<DynamicImage, Error>
where
@@ -485,7 +485,12 @@ fn base64_to_image<D: AsRef<[u8]>, P: Pixel>(base64_data: D) -> Result<Image<P>,
_ => return Err(Error::UnsupportedPixelType(core::any::type_name::<P>())),
};
Ok(Image { data: result_data, width, height })
Ok(Image {
data: result_data,
width,
height,
base64_string: None,
})
}
pub fn pick_safe_imaginate_resolution((width, height): (f64, f64)) -> (u64, u64) {