@davidfor: There's a fair bit of whitespace killing noise in the patch, yes (blame that on my text editor settings). I'm wary of building a diff with bB to skip those because that might be critical for Python code, and end up generating a broken diff. I'll check, though

.
minify_to: Yeah, that's basically the bounding box/canvas size. In this case, it pretty much always should match the exact size we're scaling to, *except* when doing letterboxing. Which is (hopefully) how the patch is using it.
Full size scaling w/ Keep AR: Yep, agreed, which is what's the patch also doing (granted, only if uploadgrayscale is enabled right now)

.
EDIT: There, patch should be less noisy

.
EDIT²: v3, which switches the scaling algorithm to Lanczos for eink covers. Slightly sharper, and the downside of slightly more ringing is usually alleviated by the dithering. Performance should be comparable.
EDIT³: v4, mostly nothing new. Just confirmed that we can't avoid the extra scaling pass made by nickel itself when it adds the deadzone covered by the bezel on the Aura & H2O.
EDIT⁴: v5, made the letterboxing optional. Still looks good on my H2O, and looks better with full screen sleep covers disabled on the Kobo.
cf.
#247 for examples.
EDIT⁵: v6, 3 years later

. Ported to the current Calibre codebase

.
This no longer needs to patch C/C++ code, so it's pure Python.
Also a tiny patch to the Kobo Utilities plugin to make testing the letterboxing codepath easier.
EDIT⁶: v7, now with PNG support, because that just makes much more sense, and it happens to work flawlessly on my device

.
EDIT⁷: v8, achieved pixel-perfect results w/ letterboxing on my H2O, despite its quirky top 11px

.
EDIT⁸: v9, double-checked the other thumbnails size on my H2O, while I was there. One was off by 2px, the horror!

.
EDIT⁹: v10, inconsequential tweak to a string.
EDIT¹⁰: v11, rebased against Calibre 3.36.0, fixed a few letterboxing issues, and reintroduced dithering as a dedicated option, following some
tests on FW 4.12...
EDIT¹¹: v13, a few code cleanups, and made the new settings more robust to make nonsensical combinations impossible.
EDIT¹²: Refreshed KoboUtilities for v13

.
EDIT¹³: Resynced KoboUtilities w/ v2.7.0

.
EDIT¹⁴: Resynced KoboUtilities w/ v2.8.0

.
EDIT¹⁵: v16, revamped dimension computations, greatly enhanced dithering, better PNG encodes.
EDIT¹⁶: Tweaked the PNG encoding process to speed it up (twice as fast as the first v16 implementation).
EDIT¹⁷: Latest iteration in the
Calibre PR 
.
EDIT¹⁸: Tweaked KoboUtilities checkbox layout to match latest driver changes.
EDIT¹⁹:
This is now included in Calibre >= 3.44.0 
.
EDIT²⁰:
This is now included in Kobo Utilities >= 2.9.0 
.