Expand description
A file that is to be attached to a note, before it goes anywhere: what kind of file it is, how large a picture it is, and the picture without what it says of where, when, with what and by whom it was made.
A photograph says a good deal more than what it shows: where it was taken, when, with which camera, what it was edited with, who it is credited to, and sometimes a smaller copy of what it showed before it was cropped. None of that is for a media server, or for whoever looks at the note. So a JPEG, a PNG or a WebP is sent as the picture and no more: of what the file is made of, only what the picture needs to look as it did is kept, and everything else is left out, whatever it is.
| Format | Kept | Left out |
|---|---|---|
| JPEG | The tables, frames and scans; of the application segments, the JFIF header, the colour profile (ICC) and Adobe’s colour marker | Every other application segment (EXIF, XMP, IPTC, MPF, content credentials, makers’ own), the comments, and whatever follows the end of the picture |
| PNG | The header, the palette, the picture data, transparency, colour (gamma, chromaticities, sRGB, ICC, HDR), pixel size, background, animation | Every other chunk (text, EXIF, the time it was changed, content credentials, makers’ own), and whatever follows the end |
| WebP | The picture data, alpha, the colour profile, animation | EXIF, XMP, and every chunk that is none of those |
This is done to the bytes of the file, and the picture data is copied as it is: nothing is decoded and encoded again, so nothing of the picture is lost.
One thing is put back. A camera held sideways writes the picture as its sensor saw it and says in the EXIF which way is up; without that the picture lies on its side. Which way is up says nothing of where or with what, so a picture that is not upright as written gets an EXIF block that says that and nothing else.
What comes out is then decoded, to make sure it is still a picture. If
it is not, while the file as it was is, the file is refused
(MediaError::Damaged) rather than sent as it was: what was to be
left out is still in it.
Other files go as they are: a GIF, a video, a sound. A video may say where it was taken, and that is not taken out of it here.
Structs§
- Bare 🔒
- A picture’s file with nothing in it but the picture, and which way up the file it was made from said the picture is: 1 to 8, as EXIF counts them, where 1 is as written.
- Media
- A file ready to be sent to a media server.
Enums§
- Media
Error - Why a file is not attached.
Constants§
- ANY 🔒
- What a file that is not known to be anything is called.
- JPEG_
EXIF 🔒 - How a JPEG’s EXIF segment starts, before the EXIF block.
- MAX_
BYTES - The largest file that is attached. It is read into memory whole, to be hashed and sent.
- ORIENTATION_
TAG 🔒 - The EXIF tag that says which way up a picture is.
- PNG_
KEPT 🔒 - The chunks of a PNG that are part of the picture: its header, palette and data; transparency; what its colours are (gamma, chromaticities, sRGB, a profile, significant bits, and the three that say how bright and in which colour space); how large a pixel is; its background; suggested palettes; and animation.
- PNG_
SIGNATURE 🔒 - How a PNG starts.
- WEBP_
HAS_ 🔒EXIF - In the header of the extended format, the flags that say there is EXIF, and that there is XMP.
- WEBP_
HAS_ 🔒XMP - WEBP_
KEPT 🔒 - The chunks of a WebP that are part of the picture: its data, lossy or lossless; the header of the extended format; alpha; the colour profile; and animation.
Functions§
- bare_
jpeg 🔒 - The JPEG
bytesas the picture and no more.Noneif it is not put together as a JPEG is. - bare_
png 🔒 - The PNG
bytesas the picture and no more.Noneif it is not put together as a PNG is. - bare_
webp 🔒 - The WebP
bytesas the picture and no more.Noneif it is not put together as a WebP is. - end_
of_ 🔒scan - Where the picture data that starts at
fromin the JPEGbytesends: at the next marker that is none of its own, which are the stuffed zero, the restart markers and fill bytes. - jpeg_
keeps 🔒 - Whether the segment of a JPEG marked
marker, which holdspayload, is part of the picture. Everything is, but the application segments and the comments; and of the application segments the JFIF header, the colour profile, and Adobe’s marker, which says how the colours are written. - kind_of
- What kind of file
bytesare, by how they start; or, for what does not say, by what the namenameends in. - orientation_
in 🔒 - Which way up the EXIF block
tiffsays its picture is, if it says, and says one of the eight there are. An EXIF block is a TIFF file: a header that says which end its numbers start at and where its first directory is, and that directory, twelve bytes to an entry. - orientation_
only 🔒 - An EXIF block that says the picture is
orientationway up, and nothing else: a directory of that one entry. - png_
chunk 🔒 - The PNG chunk called
namethat holdsdata. - png_crc 🔒
- The checksum a PNG chunk ends in, of its name and what it holds, which
are
bytes: CRC-32. - prepare
- The file called
namethatbytesare, ready to be sent: a JPEG, a PNG or a WebP as the picture and no more (see the module), and anything else as it is. - to_say 🔒
- The orientation that is to be said again: one that is not as written.