fix(widget): round iOS cover thumbnail size to whole pixels (#4950)

The iOS reading widget downsampled covers to a fractional target size.
UIGraphicsImageRenderer allocates a whole-pixel buffer while draw(in:)
fills only the exact fractional rect, so for portrait covers whose scaled
width rounds up the rightmost pixel column was left partially covered and
semi-transparent. Encoded to JPEG that column flattened into a visible
bright hairline along the right edge (intermittent, portrait covers only).

Round both target dimensions to whole pixels so the draw rect matches the
pixel buffer and every edge pixel is fully covered. Android is unaffected
because it scales to a fixed 240x360 and center-crops.

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Huang Xin
2026-07-06 03:24:40 +09:00
committed by GitHub
parent e7f0b53bdf
commit 9321c2cd39
@@ -41,7 +41,13 @@ enum ReadingWidgetWriter {
}
let longEdge = max(image.size.width, image.size.height)
let scale = longEdge > thumbMaxPixels ? thumbMaxPixels / longEdge : 1
let target = CGSize(width: image.size.width * scale, height: image.size.height * scale)
// Round to whole pixels: the renderer allocates a whole-pixel buffer, so a
// fractional target would leave the trailing pixel column/row only partially
// covered (semi-transparent). Flattened into JPEG that shows up as a bright
// hairline along the right/bottom edge. Whole-pixel target == full coverage.
let target = CGSize(
width: (image.size.width * scale).rounded(),
height: (image.size.height * scale).rounded())
let format = UIGraphicsImageRendererFormat()
format.scale = 1.0
let renderer = UIGraphicsImageRenderer(size: target, format: format)