Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.27.2
require (
github.com/go-gfx/gfx v0.41.0
github.com/go-images/images v0.3.0
github.com/go-images/jpeg v0.3.0
github.com/go-ooxml/ooxml v0.7.0
github.com/go-ooxml/opc v0.2.1
github.com/go-pdfkit/document v0.2.0
Expand All @@ -28,7 +29,6 @@ require (
github.com/go-browserhttp/browserhttp v0.2.0 // indirect
github.com/go-gfx/oksvg v0.2.0 // indirect
github.com/go-images/gif v0.2.0 // indirect
github.com/go-images/jpeg v0.3.0 // indirect
github.com/go-images/jpeg2000 v0.14.0 // indirect
github.com/go-images/png v0.2.0 // indirect
github.com/go-opentype/fonts v0.14.0 // indirect
Expand Down
15 changes: 14 additions & 1 deletion redactimage.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,21 @@ import (
"fmt"
"image"
"image/draw"
"image/jpeg"

// ⛔ 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.
//
// ⛔ 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.
"github.com/go-images/jpeg"
"github.com/go-pdfkit/extract"
"github.com/go-pdfkit/reader"
)
Expand Down
9 changes: 8 additions & 1 deletion redactjpeg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ var bottomQuarter = Redaction{Page: 1, Quads: []Quad{{
//
// ⛔⛔ THE KEPT SAMPLES ARE COMPARED AGAINST THIS TEST'S OWN DECODE OF THE
// ORIGINAL JPEG, BYTE FOR BYTE. That is the whole claim the lossless path
// makes. Asserting a colour instead would be asserting what an encoder does
// makes.
//
// ⛔ AND THE TWO DECODERS ARE NOT THE SAME ONE. This file encodes and decodes
// with the standard library's image/jpeg; redactimage.go decodes with
// go-images/jpeg, the fork go-pdfkit/render shows the reader. So the equality
// below is also the statement that the two agree on a three-component picture
// — and the day they stop agreeing, this goes red and names the row and column
// where. Importing the fork here as well would have thrown that away. Asserting a colour instead would be asserting what an encoder does
// with it, which is a different subject and a moving one; and asserting "it
// still looks about the same" would pass for a picture re-encoded into mud —
// which is what re-encoding as a JPEG would have done to every block of it,
Expand Down
Loading