MCPcopy Create free account
hub / github.com/MegEngine/MegFlow / into_response

Method into_response

flow-plugins/src/utils/image.rs:110–126  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

108impl Reply for Image {
109 #[inline]
110 fn into_response(self) -> reply::Response {
111 use image::codecs::jpeg::JpegEncoder as Encoder;
112 let mut buf = vec![];
113 let mut encoder = Encoder::new(&mut buf);
114 encoder
115 .encode(self.as_bytes(), self.width(), self.height(), self.color())
116 .unwrap();
117 let len = buf.len();
118 let mut resp = reply::Response::new(Body::from(buf));
119
120 resp.headers_mut().typed_insert(ContentLength(len as u64));
121 resp.headers_mut()
122 .typed_insert(ContentType::from(Mime::from_str("image/jpeg").unwrap()));
123 resp.headers_mut().typed_insert(AcceptRanges::bytes());
124
125 resp
126 }
127}
128
129async fn extract_image(

Callers

nothing calls this directly

Calls 2

widthMethod · 0.80
lenMethod · 0.45

Tested by

no test coverage detected