Skip to main content

Teaching Featherview to read Photoshop’s layers

Featherview 0.13 draws Photoshop files from their layers, and 104 of 108 test files match Photoshop’s own result.

Updated 4 min readMarkdown

Hubble’s Andromeda mosaic is a single Photoshop file of 4.6 GB. I picked it as a stress test for Featherview, my image viewer for the Mac. If that file opens like a holiday JPEG, everything else will. Today it’s on screen about two seconds after the double-click, launch included.

https://x.com/mynetx/status/2117620657148059858

To get there, Featherview had to stop handing big Photoshop files to Apple’s ImageIO and read them itself. And once you read PSDs yourself, you meet the files that don’t want to be read.

The picture that isn’t there

Some Photoshop files keep a placeholder where the picture should be.

A PSD stores two things: its layers, and one flattened copy of the whole picture. Viewers show the flattened copy. But if you save from Photoshop with “Maximize Compatibility” turned off, that copy is only a placeholder. The real picture exists in the layers and nowhere else.

I collected 513 PSD and PSB files from the test folders of three open-source Photoshop libraries, plus 28 from this Mac. 62 of them have no real flattened copy. ImageIO showed 24 of those as one flat colour.

So Featherview 0.13 draws those files from their layers.

Stacking layers, the long version

It sounds simple. Put the layers on top of each other, done. In practice every layer has a blend mode and an opacity, and maybe a mask or a clipping mask. Layers sit in groups. A group either blends as one unit or passes its layers straight through to whatever is below. Then there are fill layers and adjustment layers, which change everything beneath them.

Featherview now draws all 27 of Photoshop’s blend modes. It handles groups, layer and vector masks, clipping masks and Blend If. Solid colour, gradient and pattern fills work, and so do 15 kinds of adjustment layer, from Levels and Curves to Selective Color and Gradient Map. A 12-megapixel file with 30 layers fits the screen in under 300 ms.

Clean room, with a referee

Featherview is a clean-room project: none of its code may come from another product. So I never read a line of those three libraries. Their test files were data, nothing more. The file format comes from Adobe’s published specification, the blend formulas from the W3C’s Compositing and Blending standard.

That leaves a question. Without anyone else’s code to compare with, how do you know your picture is right?

The answer was in the test files all along. About 350 of the layered files do store a real flattened copy, and that copy is Photoshop’s own answer. So Featherview draws those files from their layers as well, ignores the stored copy, and then compares the two. A file passes when its colours are off by at most 1 on average, on a scale of 0 to 255, and fewer than 1 % of its pixels are off by more than 8.

Counted once per unique file, 108 files could be compared. 104 pass.

The last four

Four files stay off, and each one has a reason.

The first full run passed 101 of 108. The misses were small and specific. Photoshop blends text layers in a different gamma, for example, and softens feathered masks in its own way. Each one was found by comparing the two pictures region by region, then fixed with a test of its own.

Four files still miss the target. Their causes are Brightness/Contrast’s curve, Hue/Saturation on near-grey colours, gradients that Photoshop mixes in its working colour space, and noise gradients, whose random generator isn’t in Adobe’s specification. Each of them has a note in the code. Layer effects such as shadows, glows and strokes aren’t drawn yet either. Those files show without them.

How it was built

Featherview is built with AI coding agents, and this milestone shows how that works. A written spec says what the app should do, and I decide what goes in. An agent turns each milestone into a plan of small tasks, each with its tests written first. Other agents build the tasks in parallel, and every task gets three independent reviews before it’s merged.

For the layers, though, the reviews weren’t the final word. The oracle was. An agent can argue that its blend formula is right. It can’t argue with 108 of Photoshop’s own pictures.

Try it

Featherview is free and open source under the MIT license. Version 0.13 brings the layers, the huge pictures and a browser for your Photos albums. Install it with Homebrew:

brew install --cask featherview/tap/featherview

Or download it from featherview.mynetx.net. It isn’t notarized yet, so a downloaded copy needs one Terminal line before its first launch. Homebrew does that for you.

Now open that PSD that used to look blank.

About the author

  • Full-stack dev, remote. I make Featherview, a free image viewer for the Mac. Ex-Twitter translator, phpMyAdmin alumnus. Pidgin & Deutsch. #JW ☀️

No comments yet. Be the first to comment.