MCPcopy Create free account
hub / github.com/evilsocket/cake / encode_png

Function encode_png

cake-core/src/cake/sharding/api/image.rs:16–24  ·  view source on GitHub ↗

Encode an RGB image buffer to PNG bytes.

(image: &image::ImageBuffer<image::Rgb<u8>, Vec<u8>>)

Source from the content-addressed store, hash-verified

14
15/// Encode an RGB image buffer to PNG bytes.
16fn encode_png(image: &image::ImageBuffer<image::Rgb<u8>, Vec<u8>>) -> Vec<u8> {
17 let dynamic_image = DynamicImage::ImageRgb8(image.clone());
18 let mut png_bytes = Vec::new();
19 let mut cursor = Cursor::new(&mut png_bytes);
20 dynamic_image
21 .write_to(&mut cursor, ImageFormat::Png)
22 .unwrap();
23 png_bytes
24}
25
26// ── Legacy image endpoint (/api/v1/image) ──
27

Callers

nothing calls this directly

Calls 1

cloneMethod · 0.45

Tested by

no test coverage detected