SubtitleEdit/subtitleedit · error · FormatException
Resolution '{input}' is invalid. Width and height must be po
Error message
Resolution '{input}' is invalid. Width and height must be positive integers. What it means
Thrown by ResolutionParser.Parse when the WIDTHxHEIGHT structure is valid (separator present) but either side fails `int.TryParse` (NumberStyles.None — no sign/decimal) or parses to a non-positive value. The tuple requires two positive integers; negatives, decimals, letters, or zero all fail.
Source
Thrown at src/seconv/Core/ResolutionParser.cs:32
{
throw new FormatException("Resolution is empty.");
}
var s = input.Trim();
var idx = s.IndexOfAny(['x', 'X']);
if (idx <= 0 || idx == s.Length - 1)
{
throw new FormatException($"Resolution '{input}' is invalid. Expected WIDTHxHEIGHT, e.g. 1920x1080.");
}
var wPart = s[..idx];
var hPart = s[(idx + 1)..];
if (!int.TryParse(wPart, NumberStyles.None, CultureInfo.InvariantCulture, out var w) ||
!int.TryParse(hPart, NumberStyles.None, CultureInfo.InvariantCulture, out var h) ||
w <= 0 || h <= 0)
{
throw new FormatException($"Resolution '{input}' is invalid. Width and height must be positive integers.");
}
return (w, h);
}
}
View on GitHub (pinned to 17a9f07487)
Solutions
- Use two plain positive integers separated by 'x': `1920x1080`.
- Remove spaces, commas, or signs from either dimension.
- Round fractional values to the nearest integer (resolutions are integral pixel counts).
- Confirm there are no hidden non-breaking spaces (U+00A0) — retype the value.
Example fix
# before seconv in.sup out.bdnxml --resolution=1920x1080.5 # after seconv in.sup out.bdnxml --resolution=1920x1080
Defensive patterns
Strategy: validation
Validate before calling
var parts = input.Split('x', 'X');
if (parts.Length != 2 ||
!int.TryParse(parts[0], NumberStyles.None, CultureInfo.InvariantCulture, out var w) ||
!int.TryParse(parts[1], NumberStyles.None, CultureInfo.InvariantCulture, out var h) ||
w <= 0 || h <= 0)
throw new ArgumentException("Width and height must be positive integers"); Type guard
static bool AreDimensionsPositiveIntegers(string? s)
{
if (string.IsNullOrWhiteSpace(s)) return false;
var p = s.Split('x', 'X');
return p.Length == 2
&& int.TryParse(p[0], NumberStyles.None, CultureInfo.InvariantCulture, out var w)
&& int.TryParse(p[1], NumberStyles.None, CultureInfo.InvariantCulture, out var h)
&& w > 0 && h > 0;
} Try / catch
try { var res = ResolutionParser.Parse(input); }
catch (FormatException ex) when (ex.Message.Contains("must be positive integers"))
{
// round/clamp or reprompt
} Prevention
- Strip whitespace and thousands separators before parsing.
- Reject non-integer inputs at arg-parse time.
- Reject zero/negative dimensions explicitly.
When it happens
Trigger: Calling `ResolutionParser.Parse(input)` with values like '1920x1080.0', '-1x1080', '1920x0', '1920xabc', ' 1920 x 1080 ' (internal spaces break int.TryParse of the substring).
Common situations: Including a decimal/fractional resolution; a leading sign; embedded spaces between number and separator; scientific notation; copy-paste introducing a non-breaking space inside a number.
Related errors
- Resolution is empty.
- Resolution '{input}' is invalid. Expected WIDTHxHEIGHT, e.g.
- Offset is empty.
- PAC code page is empty.
- PAC code page '{input}' is invalid. Expected a name (Latin,
AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13).
Data as JSON: /api/errors/7ec1cebe14495df5.
Report an issue: GitHub.