Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6d1453d
The label drawn in a picture no longer states the size of the file
donislawdev Nov 16, 2026
21f6ad0
A size refused for a batch names the size every file of it takes
donislawdev Nov 16, 2026
620146b
The reservation guard asks about a size above what the format makes
donislawdev Nov 16, 2026
04d9f57
Smallest is a way of giving the size in the window
donislawdev Nov 17, 2026
26e5e58
Placeholder settings appear only while content is placeholder
donislawdev Nov 17, 2026
6bb2eec
English lists name their values and settings have readable labels
donislawdev Nov 17, 2026
be2784f
The window's own sentences say what the screen shows, and a switch re…
donislawdev Nov 17, 2026
54f321f
A refusal in the English window names list values and settings as the…
donislawdev Nov 17, 2026
57c2b74
A refusal in the window speaks of batches and boxes, not of a recipe
donislawdev Nov 17, 2026
5380687
Mutation entries point at the code they guard again
donislawdev Nov 17, 2026
9852ebf
A preset of picture sizes: screens, avatars and social platforms
donislawdev Nov 17, 2026
63e71f2
The mouse wheel scrolls the window as far as the system says
donislawdev Nov 17, 2026
81ce0cb
Three mutation entries break what they name again
donislawdev Nov 17, 2026
3438a40
Two switches on a setting's kind say what the other kinds do
donislawdev Nov 17, 2026
1a2524a
CI on ubuntu-26.04: GNU sha256sum by its name there, site guards weighed
donislawdev Nov 17, 2026
e9512ab
One picture refused for its size gets one button, not two
donislawdev Nov 17, 2026
bff8523
Smallest stays greyed out until a picture has its width and height
donislawdev Nov 18, 2026
c12305b
A value to type stands out from the words that describe it
donislawdev Nov 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
16 changes: 12 additions & 4 deletions .github/race-weights
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
# Listed: every test that took 10 s or more. "unlisted" is the mean of the rest.
# TestSmallestIsTheSmallestFile came on 2026-11-16: 79.3 s in a part whose
# listed tests took 0.61 of their weights, so 130.1.
# The seven site guards that ask the program about every preset share one
# answer per process, so the first of them in a part pays for it: 52 to 61 s
# on 2026-11-18, against 16 to 26 s before, because the picture-sizes preset
# plans its 21 pictures at their smallest twice (tfg preset show, a dry run).
# Each weighs what it took where it paid, the rest the most any of them paid.
#
# A test that is not here and takes 60 s or more fails its part with the line
# to add. A test that is here and no longer exists fails every part.
Expand All @@ -36,11 +41,18 @@ unlisted 0.58
65.6 TestADamagedFileIsExactlyTheSizeAskedFor
64.6 TestNoTrackedFileCarriesPrivateContent
62.2 TestEveryDamageIsRefusedByTheStructuralCheckInEveryFormat
60.6 TestEveryLanguageDescribesEveryDamage
60.6 TestEveryLinkOnTheSiteLeadsSomewhere
60.6 TestTheSitemapNeedsNoSchemaButItsOwn
60.6 TestTheSocialPictureShowsTheCardAsItIsNow
60.0 TestEveryPageSaysWhichLanguageItIsAndWhereItsTranslationsAre
59.3 TestTheSiteSaysWhatTheToolSays
57.3 TestAFilmSaysItCarriesItsLabelOnlyWhenAPictureShowsItWhole
55.6 TestEveryJxlRungStillFitsInsideItsDeclaredCeiling
55.6 TestTheArchiveScanLooksIntoTheArchivesInside
55.3 TestAFilmOfANamedSizeKeepsEveryPictureInsideItsReserve
52.2 TestChoosingAToolLaysTheScreenOutAsIfItOpenedWithIt
52.0 TestEveryLanguageDescribesEverythingTheProgramCanProduce
38.6 TestAContainerStopsBetweenTheFilesItPlans
37.5 TestEveryPictureNamedAfterARefusalShowsOne
36.7 TestJxlStillFitsWhenTheQualityIsNotTheOneTheCeilingsWereMeasuredAt
Expand All @@ -49,13 +61,11 @@ unlisted 0.58
34.0 TestOurOwnGeneratorsHaveNotDrifted
29.9 TestTheSameSeedGivesTheSameBytes
27.9 TestTheMinimumStandsWhateverTheSeedIsUnderEveryDeclaredChoice
25.9 TestEveryLinkOnTheSiteLeadsSomewhere
24.9 TestEveryEMLSettingSurvivesItsReferenceTool
24.2 TestAPictureSaysItCarriesItsLabelOnlyWhenItsTextIsWhole
23.2 TestAnAVIFLargerThanOneAV1TileSurvivesItsReferenceTool
23.1 TestACutTakesTheShareOfTheContentItIsAskedFor
22.4 TestTheLadderCeilingIsAboveEveryPictureTheTopRungMakes
22.2 TestTheSiteSaysWhatTheToolSays
20.9 TestAFilmsProgressMovesWithItsPicturesNotItsPadding
20.7 TestAFilmHoldsTheFramesTheManifestDeclares
20.7 TestTheWindowBinaryStartsWithoutAConsole
Expand All @@ -64,8 +74,6 @@ unlisted 0.58
17.4 TestThePresetScreenKeepsTheNameAFileIsSentUnder
17.0 TestTheSmallestDamagedFileIsTakenAndOneByteLessIsNot
16.9 TestEveryFormatSurvivesItsReferenceTool
16.7 TestEveryLanguageDescribesEverythingTheProgramCanProduce
16.6 TestEveryLanguageDescribesEveryDamage
16.3 TestTheSameWorkDoneAgainLeavesTheWindowAsItWas
16.2 TestABuildWithNoWindowInItSaysSoAndKeepsStandardOutputEmpty
15.4 TestAvifStillFitsWhenTheQualityIsNotTheOneTheCeilingsWereMeasuredAt
Expand Down
95 changes: 88 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ because it turns other people's test suites red.

### Breaking

- **The label drawn in a picture no longer states the size of the file.** It
reads `tfg - png - seed c2a547b2`, with any damage before the seed. A picture
of a given width and height is then the same at every size you ask for, so
the smallest size a refusal names is accepted next time. Before, it could be
refused again. The label also fits narrower pictures than before.
Labelled pictures and films, and mails, HTML pages and RTF documents with
pictures, are not byte for byte what 0.5.0 wrote. Text formats still state
the size.
- **A JPEG XL or a film just above the size where its picture grows gets the
smaller picture.** A JPEG XL now steps up to 256x256 at 7509 B and to
320x240 at 10213 B, and a WebM or MP4 film to 320x180 at 8697 B, because
the label is drawn larger there. A file between the old step and the new one
is not byte for byte what 0.5.0 wrote.
- **A TIFF of an odd size is not byte for byte what 0.5.0 wrote.** Its
directory, which says where the pixels are, came last and so started on an
odd byte, where the TIFF specification has it start on an even one. Every
Expand All @@ -39,7 +52,7 @@ because it turns other people's test suites red.
wrote. Files with no damage, and files made with `--clean`, are unchanged.
- **An AVIF file just above the size where its picture grows gets the smaller
picture.** The picture now steps up to 160x120 at 3865 B, to 256x256 at
5493 B, to 320x240 at 7732 B and to 640x480 at 18722 B, about a tenth above
6140 B, to 320x240 at 7732 B and to 640x480 at 18722 B, a tenth or more above
where it did. A file between the old step and the new one is not byte for
byte what 0.5.0 wrote.
- **A tar.gz 16 KiB to 64 KiB larger than the files inside it now opens in
Expand All @@ -59,23 +72,38 @@ because it turns other people's test suites red.

### Added

- **A preset of picture sizes.** `tfg generate --preset picture-sizes` writes
a picture at each of 21 common sizes: HD, Full HD, QHD and 4K screens,
profile pictures, and the covers, posts and thumbnails YouTube, Facebook, X,
LinkedIn, Instagram and Pinterest ask for, read from their help pages in
November 2026. Each is as small as it can be and named by its size, such as
`1920x1080.jpg`. `--groups` picks screens, avatars or social,
`--content placeholder` draws the size on each picture, and `--format` takes
any picture format. A size the format cannot draw is left out and named.

- **Placeholder pictures.** `--set content=placeholder` on `png`, `jpg` and
`svg` draws a flat colour with words in the middle, for laying out a page
before the real pictures exist. The words are the picture's size unless
`text` says otherwise, and `{width}`, `{height}`, `{index}` and
`{index:04}` in it become each file's size and number. `background` and
`foreground` take a colour such as `cccccc`, and `guides` draws a frame,
both diagonals and a circle. In a recipe write a colour without the `#` or
in quotes, because YAML reads `#` as the start of a comment. The test
pattern is unchanged.
in quotes. The window shows these four once Content is placeholder. The
test pattern is unchanged.

- **`tfg formats` says when a setting changes nothing.** A setting that
changes a file only while another setting has a certain value ends its line
with that, such as `only when content is placeholder`, and `tfg formats
--json` gives it as `only_when`. Such a setting is refused while it would
change nothing, as before.

- **`smallest` as a size.** `--size smallest`, or `size: smallest` in a
recipe, makes each picture as small as it can be at the `width` and
`height` you set, in all ten picture formats, and `--dry-run` still says the
size to the byte. With the label on, the label states the file's size and
its numerals change how a PNG or a JPG compresses, so it can carry up to
about a kilobyte more than its picture needs. With `--clean` the file is the
picture alone.
size to the byte. The file is the picture alone, with nothing added to reach
a size, whether the label is drawn in it or not. In the window it is
Smallest under How the size is given, on Single batch and Several batches,
for pictures, greyed out until the width and height are set.

- **Generate into the same folder again.** A run into an output directory
that already holds an earlier run is added beside it: every name of the run,
Expand Down Expand Up @@ -235,6 +263,48 @@ because it turns other people's test suites red.

### Changed

- **A value to type stands out from the words describing it.** In the
explanation behind a field, a value you type as it is - `screens` and `all`
for the groups of `picture-sizes`, `10mb` for a size, `{index:04}` in a file
name, `cccccc` for a colour - is drawn in a code typeface and its own colour.
The site shows it as code, and `tfg preset show` and `tfg formats` print it
between backticks.
- **The mouse wheel scrolls the window as far as the system says.** One notch
moves three lines of text, or as many as Windows is set to under Mouse,
Lines to scroll at a time, where it moved about half as far before. A
setting of one screen at a time is followed too. On Linux a notch is three
lines, and on macOS scrolling is unchanged.

- **The window names list values and settings in words.** An English list
shows test pattern rather than test, rising tone rather than sweep and file
count limit rather than count_limit. Settings such as PDF version, Bounding
box and Records per line are no longer spelled out of their keys, and the
note under Width and Height calls them that. A recipe and the command line
write values and keys as before. The sentences `tfg formats` prints under
these settings use the same words, and a box for the format of the files
inside reads `such as png or csv`.
- **The window's own sentences say what the screen shows.** Single batch no
longer promises one size. The explanations behind Seed, Label in each file,
Size, Limit to test, Expected outcome and Preset say what each does without
words from inside the program, and About names the tabs and buttons it
means. A switch reads on or off rather than true or false, in the line of a
folded section and behind its button. The memory setting on Preferences is
described in plain words.
- **A refusal in the window names settings and list values as the screen
does.** In English it read "level_mix and entry_format" and "the
apache-combined shape", and now reads "Level mix and Entry format" and "the
Apache combined shape". In Polish the same refusal at the bottom of the form
left the setting's name out entirely. The command line prints every refusal
as before. The Polish label of Entry format now suits a log as well as an
archive.
- **A refusal in the window speaks of batches and boxes, not of a recipe.**
It read "target 1 has no Size ... add size: 2mb, size-range: 1kb-8kb", and now
reads "Batch 1 has no Size ... type a size such as 2mb, or choose another way
under How the size is given". Hints name a box, a list or a tab rather than
a line of a recipe or a `tfg` command. The command line keeps its words,
except a few reasons that spoke of a recipe, such as "so the same settings
give the same files everywhere".

- **On Windows, a path picked with Choose... has backslashes.** It is written
the way Windows writes paths, the same text a drop of that folder or file
puts in the box. It came with forward slashes before.
Expand Down Expand Up @@ -293,6 +363,17 @@ because it turns other people's test suites red.

### Fixed

- **The smallest size a refusal names is one every file of the batch takes.**
Three 320x240 PNGs asked for at 1 B named the smallest size of the first
file, and that size was refused again, because each picture needs its own.
The refusal now names the smallest size every file can have, and the button
under it in the window puts that size in the box. Refusing a large batch
takes about as long as planning it. Several pictures with a width and height
also get a second button, for `smallest`, each at its own size.
- **Several batches shows a format's settings the way Single batch does.**
The settings of a PDF stand under their headings there too, and a setting
that is a size, such as Entry size of a ZIP, shows its count of bytes under
the box. The same goes for the settings of a preset a batch builds on.
- **Choose... is off while files are being made.** The output directory box
was frozen during a run and the button beside it was not, so a folder picked
mid run went into the box while the run went on writing into the old one.
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ for, and the manifest says how your system should react to it:
|---|---|
| `empty-and-minimal` | Does a file that is valid and as small as the format allows get through? |
| `filename-handling` | Will my system store, show and give back a file name it did not expect? |
| `picture-sizes` | Does my system take pictures at the sizes screens and platforms use? |
| `size-boundaries` | Is a size limit enforced exactly where it is declared? |
| `tabular-import` | Does my table import survive what real tools export? |
| `text-encoding` | Does my reader know which encoding a file is in, or is it guessing? |
Expand Down Expand Up @@ -528,8 +529,11 @@ tfg generate --format zip --size 5mb --damage truncate:missing=30
A damaged file names its damage in its label, beside the size it has on disk:
`tfg - txt - 10485760 B - damage truncate:missing=50 - seed c2a547b2`. So two
texts cut by different shares can be told apart from their first line, although
the text after it is the same. A long list of damages names the first few and
how many more there are, and the manifest lists every one. The label is still
the text after it is the same. A picture or a film draws its label without the
size, `tfg - png - damage zero-head:bytes=16 - seed c2a547b2`, so a picture of a
given width and height is the same picture at every size you ask for. A long
list of damages names the first few and how many more there are, and the
manifest lists every one. The label is still
written before the damage, so the damage can overwrite it, and the manifest does
not promise it is there.

Expand Down
36 changes: 34 additions & 2 deletions internal/cli/formats.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,38 @@ type propertyEntry struct {
// is every one a preset, a damage or a tool takes. Added on 2026-11-11,
// which widens this output and changes the meaning of no key in it.
Extensions map[string]string `json:"extensions,omitempty"`
// OnlyWhen is the setting, and its values, under which this one changes
// anything - a placeholder's colours while content is placeholder. Absent
// for a setting that always does. Added on 2026-11-17, widening this
// output the way extensions did.
OnlyWhen *conditionEntry `json:"only_when,omitempty"`
}

// conditionEntry is format.Condition as --json writes it.
type conditionEntry struct {
Setting string `json:"setting"`
Values []string `json:"values"`
}

// conditionOf is a condition for --json, or nothing for a setting that has
// none, so the key is absent rather than empty.
func conditionOf(c format.Condition) *conditionEntry {
if c.IsZero() {
return nil
}
return &conditionEntry{Setting: c.Setting, Values: c.Values}
}

// allowedWithCondition is what a setting takes, and after it when it changes
// anything, for a setting that does not always: "true or false, default
// false, only when content is placeholder". On the setting's own line rather
// than once over its block, so a line read alone - grep for background - still
// says it.
func allowedWithCondition(p format.Property) string {
if p.OnlyWhen.IsZero() {
return p.Allowed()
}
return p.Allowed() + ", " + p.OnlyWhen.Describe()
}

// smallestAccepted is the number this command prints as the minimum.
Expand Down Expand Up @@ -106,7 +138,7 @@ func entryFor(d format.Descriptor) formatEntry {
props = append(props, propertyEntry{
Name: p.Name, Kind: string(p.Kind), Min: p.Min, Max: p.Max, Extensions: p.Extensions,
Unit: p.Unit, Choices: p.Choices, Default: p.Default, Detail: p.Detail,
Group: p.Group,
Group: p.Group, OnlyWhen: conditionOf(p.OnlyWhen),
})
}
return formatEntry{
Expand Down Expand Up @@ -145,7 +177,7 @@ func describeOne(d format.Descriptor, out io.Writer) {
if p.Group != "" && (i == 0 || d.Properties[i-1].Group != p.Group) {
fmt.Fprintf(out, "\n %s:\n", p.Group)
}
fmt.Fprintf(out, " %-14s %s\n", p.Name, p.Allowed())
fmt.Fprintf(out, " %-14s %s\n", p.Name, allowedWithCondition(p))
if p.Detail != "" {
fmt.Fprintf(out, " %-14s %s\n", "", p.Detail)
}
Expand Down
64 changes: 64 additions & 0 deletions internal/core/literal.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
package core

import "strings"

// A value somebody types into a box exactly as it is written - a group name, a
// placeholder in a text, a colour, a word a setting takes - stands between two
// backticks in the description of a setting: "Leave it at `all`". Each surface
// shows the marks in its own way, and the text is written once:
//
// - the window draws the value in the type of code, in a colour of its own
// (parts.Explanation), and the backticks go.
// - the site wraps it in <code>.
// - the command line prints the backticks as they are, which is how the help
// of a command marks something to type.
//
// The owner's decision of 2026-11-18, after reading the explanation of the
// groups of the picture sizes preset in the window: screens, avatars, social
// and all stood among the words describing them, and nothing said which of
// them went into the box (docs/SIZE-FIXES-2026-11-16.md section 3.9).
//
// A translation keeps every value between the marks exactly as the English has
// it, since what is typed is the same in every language -
// TestAValueToTypeIsTheSameInEveryLanguage holds every catalogue to that.

// Backtick is the mark on either side of a value to type.
const Backtick = "`"

// Piece is one run of a description: a value to type, or the words round it.
type Piece struct {
Text string
Literal bool
}

// Pieces splits a description at its marks, in order, leaving out the empty
// runs. A mark without a partner is kept as it is written, in the words: an
// odd one is a backtick somebody meant, not the start of a value.
func Pieces(s string) []Piece {
parts := strings.Split(s, Backtick)
if len(parts)%2 == 0 {
// An odd number of marks: the last one has no partner, so it and
// everything after it are words.
last := len(parts) - 2
parts = append(parts[:last:last], parts[last]+Backtick+parts[last+1])
}
out := make([]Piece, 0, len(parts))
for i, p := range parts {
if p == "" {
continue
}
out = append(out, Piece{Text: p, Literal: i%2 == 1})
}
return out
}

// Literals is every value to type in a description, in order.
func Literals(s string) []string {
var out []string
for _, p := range Pieces(s) {
if p.Literal {
out = append(out, p.Text)
}
}
return out
}
19 changes: 6 additions & 13 deletions internal/core/refusal.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ func (r *Refusal) Error() string { return r.InTheWordsOf(r.setting) }
// InTheWordsOf is the sentence with the setting named the way one surface names
// it. The slots are filled in the layout before the values go in, so a value
// somebody typed as "{setting}" is printed as typed rather than read as a slot.
func (r *Refusal) InTheWordsOf(name string) string {
func (r *Refusal) InTheWordsOf(name string) string { return r.Reworded(name, nil) }

// Reworded is InTheWordsOf with the values worded by w - see Said.Reworded.
func (r *Refusal) Reworded(name string, w Wording) string {
if name == "" {
name = r.setting
}
return r.said.InTheWordsOf(name)
return r.said.Reworded(name, w)
}

// Said is the sentence in parts.
Expand Down Expand Up @@ -74,17 +77,7 @@ func (r *Refusal) Unwrap() error {
// InTheWordsOf is String with the setting slots of the layout filled first, so
// a value somebody typed as "{setting}" is printed as typed rather than read as
// a slot.
func (s Said) InTheWordsOf(name string) string {
if name == "" {
return s.String()
}
filled := s
filled.layout = InTheWordsOf(s.layout, name)
if s.one != "" {
filled.one = InTheWordsOf(s.one, name)
}
return filled.String()
}
func (s Said) InTheWordsOf(name string) string { return s.Reworded(name, nil) }

// wrapped is every value the layout takes with %w.
func (s Said) wrapped() []error {
Expand Down
Loading
Loading