From eeb6cb22035cdb8bc04f0cef1028ed26022c79a3 Mon Sep 17 00:00:00 2001 From: tannevaled Date: Wed, 11 Nov 2026 15:59:21 +0100 Subject: [PATCH] redact: the comment accused go-images/images of a defect it documents on purpose MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ⛔⛔ I WROTE TWO CLAIMS INTO A SHIPPED COMMENT WITHOUT CHECKING EITHER, and was one command away from filing two issues in other organisations on the strength of them. The comment added in #89 said the import swap saved linking a second decoder — already corrected in that pull request, `go list -deps` says image/jpeg stays either way — and then that go-gfx/gfx/codec, go-images/images and go-pdfkit/html2pdf importing image/jpeg is "a wider divergence than this file", with go-images/images importing BOTH singled out as the worst of it. Reading that dependency's source says otherwise, and says it deliberately. Its package doc: "PNG and JPEG via the standard library". Its partial.go, which is the only file importing the fork: ⛔ One divergence from [Decode], stated rather than hidden. On a COMPLETE file this returns the FORK's decode, and for a four-component JPEG that differs: the fork upsamples chroma the way libjpeg does, where the standard library repeats each sample. Decode's standard-library path is untouched, so anything relying on its exact bytes still gets them. So the two decoders live there on purpose, the divergence is written down where the divergence is made, and there is nothing to file. A tracker entry claiming otherwise would have cost a maintainer a reading to refute. ⛔ WHAT SURVIVES THE CHECK IS THE CHANGE ITSELF. go-pdfkit/render's import list holds github.com/go-images/jpeg and NOT image/jpeg, so decoding a redacted picture with the fork really is decoding it the way the page is shown. That was the reason; the rest was decoration I had not earned. Co-Authored-By: Claude Opus 5 --- redactimage.go | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/redactimage.go b/redactimage.go index a7f2e3d..a98968f 100644 --- a/redactimage.go +++ b/redactimage.go @@ -8,17 +8,22 @@ import ( // ⛔ THE FLEET'S DECODER, NOT THE STANDARD LIBRARY'S. What this promises to // write back is "what a reader would have seen", and the reader is - // go-pdfkit/render, which decodes /DCTDecode with this fork: Go's own - // image/jpeg with a four-component picture's chroma upsampled the way - // libjpeg does rather than by repeating each sample. Decoding here with a - // different decoder would make that promise true of a picture nobody was - // shown. + // go-pdfkit/render, whose import list holds github.com/go-images/jpeg and + // not image/jpeg: Go's own decoder with a four-component picture's chroma + // upsampled the way libjpeg does rather than by repeating each sample. + // Decoding here with a different decoder would make that promise true of a + // picture nobody was shown. // - // ⛔ AND IT IS NOT ABOUT THE BINARY. This was first written claiming it - // saved linking a second decoder; `go list -deps` says otherwise, before - // and after. image/jpeg stays, because go-gfx/gfx/codec, go-images/images - // and go-pdfkit/html2pdf each import it — go-images/images imports BOTH. - // That is a wider divergence than this file, filed rather than fixed here. + // ⛔ THE REASON IS NOT BINARY SIZE, AND THE OTHER IMPORTERS ARE NOT A + // DEFECT — two claims this comment made before anyone checked them. + // `go list -deps` says image/jpeg stays either way, pulled in by + // go-gfx/gfx/codec, go-images/images and go-pdfkit/html2pdf. And + // go-images/images imports both ON PURPOSE: its own doc says PNG and JPEG + // decode through the standard library, while partial.go uses the fork for + // DecodePartial and states the four-component divergence in so many words + // — "Decode's standard-library path is untouched, so anything relying on + // its exact bytes still gets them". Two issues were nearly filed on that. + // Reading the dependency's source is what stopped them. "github.com/go-images/jpeg" "github.com/go-pdfkit/extract" "github.com/go-pdfkit/reader"