Expand description
What a computer attaches to a text, made fit for a multimedia message (docs/texts.md, “Multimedia messages sent from a computer”; decisions 6 to 10), before anything travels: so the sharing, the server and the phone only ever carry what will be sent.
- Pictures (JPEG, PNG, WebP, TIFF, BMP, a still GIF; HEIC, AVIF and
JPEG XL where Qt reads them), told by their first bytes (
sniff), are always written again as a baseline JPEG (cpp/pictures.cpp), even one that fits: their orientation applied, in sRGB, laid on white, with no metadata at all (no GPS position, camera, time, comment or colour profile); the long side at most 1,600 pixels (and the carrier’s advice), quality 85, then lowered to 50, then a quarter smaller each time, never under 480 pixels (fit). Only a picture’s own reader decodes it: never a document Qt’s plugins could also render (PDF, SVG, PostScript, a camera’s raw file). - An animated GIF goes with its frames as they are, written again
without its comments and other programs’ blocks (XMP, a profile), when
the message holds it (
gif_pictures_alone), else is refused in words. - A video, a sound, a contact card, a calendar entry, told by their
first bytes too (
sniff_medium), go as they are, with what their files hold, when the message holds them, else are refused in words. - Other files are refused, whatever their names say: a phone may never open them. Send them by mail.
- Up to five media a message (
texts::MEDIA_MAX), the pictures sharing equally what the others leave (share), 16 KB each at least; what a picture going at its best leaves goes to those made smaller.
The rules are pure and tested here; Qt only reads and writes the pictures, in a thread of their own, never the window’s (tests/attach.rs: no metadata left, each format, the whole making).
Structs§
- Attached 🔒
- One medium attached on the page, made fit: its file (in Sioul’s cache, yours alone, gone once sent or let go; named by when and its rank, never by the file chosen), what it is, its size.
- Left 🔒
- A file chosen that does not go, for the page to say why: its words’ key (“too-many”, “kind”, “unreadable”, “file”, “too-large”, “gif-too-large”, “too-many-pictures”, “picture-too-large”), its size, a picture’s format in words for “kind”.
- Picture 🔒
- A picture decoded by Qt (cpp/pictures.cpp), let go when dropped. Used on the thread that opened it.
Enums§
- Kind 🔒
- What a file attached is (decisions 7 to 9).
Constants§
- FIRST_
QUALITY 🔒 - FIRST_
SIDE 🔒 - A picture’s long side at most (OMA’s guaranteed 1600 × 1200, decision 6).
- HEAD 🔒
- How much of a file is read to tell what it is: an audio frame’s next frame with it (an AAC frame may be 8 KB).
- LAST_
QUALITY 🔒 - LAST_
SIDE 🔒 - …and at least: smaller than this, a picture is refused rather than sent unreadable.
- MIN_
SHARE 🔒 - A picture’s share at least (AOSP Messaging’s
MIN_IMAGE_BYTE_SIZE). - WORDS_
RESERVE 🔒 - What the words may take, kept out of the media’s room as they are typed: 1,600 characters of four bytes each.
Functions§
- adts_
frame 🔒 - An AAC frame’s length by its ADTS header (seven bytes): its sync, layer 0, a sampling rate that exists; none else.
- ct_of 🔒
- A medium’s content type, by its kind, once made.
- extension_
of 🔒 - A medium’s file’s extension in Sioul’s cache, by its content type (never the file chosen’s).
- first_
side 🔒 - A picture’s long side when it goes at its best: 1,600 pixels, less as
its carrier advises (
advised, 0 none), never more than its own. - fit 🔒
- A picture’s long side and quality that fit its share (decision 6):
first its long side at
first(1,600 pixels, less as its carrier advises, never more than its own) at quality 85; over its share, the quality searched down to 50, the interval halved four times at most; still over at 50, a quarter smaller and searched again; never under 480 pixels.writewrites the picture at a long side and a quality and says its size (none: not written). None: it cannot be made small enough. - format_
words 🔒 - A picture’s format in words, for “this computer cannot read … pictures”.
- gif_
pictures_ 🔒alone - An animated GIF written again with its pictures alone (the review of 18
October 2026, L-1, and of its re-check, L-c): its header, its screen and
colour tables and each frame’s image kept byte for byte; each frame’s
timing (its graphic control) written as its own four bytes alone, its
loop (NETSCAPE2.0’s or ANIMEXTS1.0’s block) as its first sub-block alone
(
01and the count), whatever else a crafted GIF puts in them; its comments, plain-text blocks, other programs’ blocks (XMP, a colour profile, an editor’s notes) and whatever follows its end left out; its end written when it lacks one (Qt reads such a GIF). No frame is decoded: each block says its own length. None for a GIF cut inside a block. - head_of 🔒
- A file’s first bytes, enough for
sniffandsniff_medium; none when it cannot be read. - kind_of 🔒
- What a file is (decisions 7 to 9), by its first bytes alone: a picture
(
picture, assnifftells it), an animated GIF when it holds several frames, refused where Qt here reads no such picture (reads); else a video, a sound, a contact card or a calendar entry (medium, assniff_mediumtells it); else another file, refused. - kind_
word 🔒 - The kind of an as-is medium, for the page’s words.
- make 🔒
- The media chosen (
sources, in their order) made fit for one message underlimitbytes (decisions 6 to 10), written intofolder: those that go, and those that do not and why.advised: the carrier’s largest picture’s long side (0 none). The room is the message’s own measure with its media empty, to the longest number, with the words’ reserve (room_for). Only regular files are read; each picture is decoded once, by its own format’s reader. - mpeg_
frame 🔒 - An MPEG audio frame’s length by its header (four bytes): its version, layer, bitrate, sampling rate and padding; none for what is no valid header (a reserved version or layer, a free or bad bitrate, a reserved rate).
- reduce 🔒
- A picture made fit for its share: written to
outasfitsays, fromsource; its long side, its quality and its size. None: it cannot be made small enough, or is no picture Qt reads here. - reduce_
picture 🔒 - A picture decoded already, made fit for its share (
reduce). - room_
for 🔒 - The bytes a message leaves for its media’s own, its media of
cts(their content types) underlimit: measured as the phone will write it (mms::room), to the longest number, its words the most they may weigh (WORDS_RESERVE), so that neither typing nor the number pushes it over. - share 🔒
- Each picture’s share of the room a message leaves for its media’s bytes (decision 10): the room less what goes as it is, shared equally, 16 KB each at least; none when it cannot be so.
- sioul_
picture_ 🔒 ⚠close - sioul_
picture_ 🔒 ⚠jpeg - sioul_
picture_ 🔒 ⚠open - sioul_
picture_ 🔒 ⚠reads - sniff 🔒
- A picture’s format by its first bytes, among those Sioul sends as a JPEG: Qt’s name for it (“jpeg”, “png”, “gif”, “webp”, “tiff”, “bmp”, “heif”, “avif”, “jxl”); none for anything else, whatever its name says.
- sniff_
medium 🔒 - A video’s, a sound’s, a contact card’s or a calendar entry’s content
type by the file’s first bytes (
head), never by its name: MP4, MOV and 3GP (ISO’s boxes, their brands), WebM, AMR, AAC, MP3, Ogg, WAV, vCard, vCalendar and iCalendar. The name only tells an MP4 of sound from one of video, which share their brands. None for anything else (a PDF named.mp4included). - webm 🔒
- Whether a Matroska file is a WebM one, by its EBML header’s DocType element (“webm”), never by “webm” anywhere in its first bytes.