Cutting the border, not the art: how ComicFlow's Trim Margins decides
ComicFlow 3.8 can trim the white or black border around each page as you read. The crop is the easy part. Deciding what counts as border, and when to leave a page alone, took a few small rules, and most of them are there to protect the art.
ComicFlow 3.8 went live on 4 November with three reading features: page curl, importing a ZIP or RAR that holds several comics, and Trim Margins. The last one is a single switch in the reader settings. Turn it on, and the white or black border around each page goes away, so the art fills more of the screen.
If you just want to know where the switch is, the Trim Margins guide on applestan.com has the steps. Here I want to write about the part you don’t see. Cropping an image is one line of code. Deciding which part of a page is border, without ever eating into the art, is a handful of small rules.
Where the borders come from
A lot of manga files are scans of printed volumes. A printed page has paper around the art, and a flatbed scanner keeps all of it. Scan with the lid open and you get the opposite: the page sits in a black frame. On a monitor nobody minds. On a phone, every millimetre of border is a millimetre the speech bubbles don’t get.
The iPhone Duo made this more visible. When it came out, Duo owners on X were already talking about pages that didn’t fill the open screen, and about the rounded corners of the outer screen. Those posts are a big part of why it went into 3.8.
The code was already there
The funny part is that ComicFlow has been finding borders since May. The export pipeline, which prepares comics for e-readers like a Kobo or a Boox, has an auto-crop option. It shrinks the page to a small copy, walks in from each edge, and stops at the first row or column that isn’t almost all white.
So for 3.8 I didn’t write a second border detector. I moved that one out of the export into a single function that takes a grayscale bitmap and returns a rectangle, and nothing else. The export calls it with its old settings, so exported books come out exactly as before. The reader calls it with a few extra rules.
Doing the work on a small copy matters more in the reader than in the export. The analysis copy is at most 256 pixels on its long edge, so a huge scan costs the same to check as a small one. And because the reader keeps the trimmed page while it’s loaded, a page is only checked once, not on every turn.
White or black, or neither
The export only ever knew white. The reader also has to handle the black frame of a lid-open scan, which raises the first question: which colour is the border?
ComicFlow looks at the outermost rows and columns of the page. If most of those pixels are very light, the border is white. If most are very dark, it’s black. If it’s neither, the art runs to the edge, and the page is left exactly as it is.
That third case is the one I care about most. A full-bleed splash page has no border, and the worst thing a trim feature can do is “find” one in the middle of a night sky.

Specks, slivers and one per cent
Real scans are messy. The border has dust, faint haze from the scanner glass and the odd stray mark. So a row doesn’t count as art the moment one pixel is dark. It counts once more than 5% of its pixels differ from the border colour. Specks stay below that, and the walk keeps going.
The opposite mistake is cutting too much. Think of a title page with one small logo in the middle, or the last page of a volume with a single line of text. Walk in from the edges and you’d end up with a tiny patch around that one dark spot, blown up to fill the screen. So there’s a floor: the trim never keeps less than 60% of the page’s width or height. If it would, the page stays whole. The export already had that rule.
And a trim can be too small to be worth it. If the biggest cut on any side is under 1% of the page, ComicFlow leaves the page alone. Otherwise every page would jump by a couple of pixels for no visible gain.
There’s one more detail that only shows up because of the small copy. One pixel in the analysis copy covers several pixels of the real page, so the edge of the crop can still hold a thin line of border. On the sides that are trimmed, ComicFlow cuts a hair further in, at least two pixels, so you don’t get a faint white line along the edge of the art.
Spreads, split pages and PDFs
Trimming one page is simple. Trimming inside a reader that already does spreads, split pages and PDFs needed a bit more care.
- Spreads. On the open Duo, a phone held sideways or an iPad, two pages often sit side by side. Each page is trimmed on its own before the spread is laid out, so a bordered page next to a clean one still lines up, and the pages still stay clear of the fold.
- Split Wide Pages. If a file stores a spread as one wide image and you read it upright in halves, the wide page is trimmed first and then cut in half. Both halves get the same crop.
- PDFs. Apple’s PDF viewer can only slide between pages, and it can’t crop them. So when Trim Margins or page curl is on, ComicFlow draws a PDF page by page, the same way it shows a CBZ. The catch is that zooming is no longer vector sharp. For scanned manga you won’t see a difference. For a crisp, text-heavy PDF you might prefer to leave the trim off.
Trim Margins is for paged reading only. In vertical scroll, a long webtoon strip has no page frame to trim, so the switch isn’t shown there. It’s also off by default, because a reader app shouldn’t change how your pages look until you ask it to.
Tests on fake pages
The detector is a function of a bitmap, so it’s easy to test without a single real comic. The tests draw synthetic pages: a dark block on a white page, a light block on a black one, a mid-grey page with art to every edge, a noisy scan edge with specks sprinkled through the border, a mostly white page with one small patch, and a page with a border so thin it shouldn’t count. Their names read like the rules above, for example testFullBleedPageIsLeftAlone and testMostlyWhitePageIsNotCutToASliver.
There’s also a check that the export still never trims black borders. I changed where its code lives, and I didn’t want it to quietly start behaving like the reader.
The Duo preset, and what I left out
ComicFlow Pro has reader presets, saved setups for different kinds of books. 3.8 adds a built-in Duo preset: paged reading, automatic page layout, fit to page, a black background, page curl and Trim Margins on. It keeps the book’s own reading direction, so it works for manga and for Western comics.
One thing I decided against for 3.8 is a “fill the whole screen” option for the outer screen. Trim Margins gets the art closer to the edges, but the page keeps its own shape. My commit for 3.8 also notes the one thing I hadn’t checked on the Duo when it shipped: how pages sit against the outer screen’s rounded corners.
If your scans have borders
Trim Margins is in the $2.99 app and doesn’t need Pro, the same as page curl and importing a ZIP or RAR with several comics. Pro is an optional $6.99 one-time unlock for comic servers, EPUB export to e-readers, reader presets like the Duo one, and Face ID-locked collections. No subscription, and no ads or ad tracking.
Your files don’t change. The trim only changes how a page is shown, so switching it off brings the full page back at once. If you have a shelf of scans with fat white edges, ComicFlow is on the App Store. Open one, switch on Trim Margins, and see how much bigger the bubbles get.