Function image_kind

Source
pub fn image_kind(bytes: &[u8]) -> Option<&'static str>
Expand description

Which supported format signature these bytes carry.

Sniffed, never taken from the address. A download that went wrong — a redirect to a login page or an error document — arrives as bytes like any other, and writing those into a music folder under the name cover.jpg is silent corruption that only surfaces months later when something tries to display it. An extension read off a URL would not catch any of it.

This checks the signature only. write_image also decodes the image and checks its complete container before publishing any bytes.

None means: do not write this.