mattermost/server/tests/exif_samples
Jesse Hallam bbbfc019a9
Replace bild imaging library with boxes-ltd/imaging (#36261)
* Add benchmarks for image transformation functions

Covers GeneratePreview, GenerateThumbnail, GenerateMiniPreviewImage,
FillCenter, and MakeImageUpright — all functions that delegate to the
external imaging library. Baseline before/after the library swap.

* Replace anthonynsimon/bild with boxes-ltd/imaging

Reverts the imaging library swap from PR #29657 (disintegration/imaging →
anthonynsimon/bild) and replaces it with github.com/boxes-ltd/imaging, the
maintained fork of disintegration/imaging with the same API.

- emoji.go: restore direct use of imaging.Fit with Lanczos filter
- orientation.go: restore FlipH/FlipV/Rotate90/180/270/Transpose/Transverse
- preview.go: restore imaging.Resize calls with Lanczos filter
- utils.go: remove bild-based Resize/Fit/CropCenter helpers; restore the
  original FillCenter using imaging.Fill
- Remove tests and test images added for the bild-specific helpers
- Regenerate orientation test expected images (2,3,6,7,8) and GIF thumbnail
  to match boxes-ltd/imaging output

https://claude.ai/code/session_012f5wLSCRQrQeRraPj282sT

* gofmt imaging package files

* Add tests and fixtures for the boxes-ltd/imaging-backed functions

Cover MakeImageUpright across all 8 EXIF orientations, GeneratePreview,
GenerateMiniPreviewImage, and FillCenter against fixtures regenerated
under the new library.

* Contain boxes-ltd/imaging behind the local imaging wrapper

Add a Fit wrapper alongside FillCenter and route emoji.go through the
local package so boxes-ltd/imaging is only imported from
channels/app/imaging.

* Add TestFit to cover the local Fit wrapper

Dimensional checks for the Fit wrapper used by emoji.go, mirroring
TestGenerateThumbnail. Pixel correctness is covered by the upstream
boxes-ltd/imaging tests; this guards against wrapper-level mistakes
(transposed args, wrong filter).

* Address CodeRabbit nits in TestFillCenter and TestFit

Decode a fresh source image per TestFillCenter subtest so cases stay
isolated even if the wrapper ever mutates input. Rename the TestFit
"smaller than bounds (clone)" case to "no resize when smaller than
bounds" since the assertion only checks dimensions, not clone semantics.

* Revert per-subtest decode in TestFillCenter

imaging.Fill never mutates its input — it always returns a fresh
*image.NRGBA — so re-decoding the source for every subtest was
unnecessary work. Decode once, share across subtests.

* Compare decoded pixels instead of raw PNG/JPEG bytes in tests

image/png isn't byte-stable across Go versions, so comparing
re-encoded byte streams against checked-in fixtures is brittle to
toolchain bumps and re-encoding. Decode both sides and compare RGBA
pixels via a shared requireSameImage helper. Fixtures stay on disk
unchanged.

Covers TestFillCenter, TestGeneratePreview, TestGenerateMiniPreviewImage,
and TestMakeImageUpright. TestFillImageTransparency is left alone since
its byte-comparison pattern predates this branch.

* Report total diff rate when requireSameImage fails

Walk every pixel before failing instead of stopping at the first
mismatch. The failure message now includes how many pixels differ, the
percentage of the image that's off, and the first divergence.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
2026-05-11 12:56:51 +00:00
..
down-mirrored.jpg [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
down-mirrored.png [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
down-mirrored.tiff [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
down-mirrored.webp [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
down.jpg [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
down.png [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
down.tiff [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
down.webp [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
left-mirrored.jpg [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
left-mirrored.png [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
left-mirrored.tiff [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
left-mirrored.webp [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
left.jpg [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
left.png [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
left.tiff [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
left.webp [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
quadrants-orientation-1.png Fix EXIF profile picture orientation bug (#34275) (#35594) 2026-03-19 15:46:21 +00:00
quadrants-orientation-2.png Replace bild imaging library with boxes-ltd/imaging (#36261) 2026-05-11 12:56:51 +00:00
quadrants-orientation-3.png Replace bild imaging library with boxes-ltd/imaging (#36261) 2026-05-11 12:56:51 +00:00
quadrants-orientation-4.png Replace bild imaging library with boxes-ltd/imaging (#36261) 2026-05-11 12:56:51 +00:00
quadrants-orientation-5.png Replace bild imaging library with boxes-ltd/imaging (#36261) 2026-05-11 12:56:51 +00:00
quadrants-orientation-6.png Replace bild imaging library with boxes-ltd/imaging (#36261) 2026-05-11 12:56:51 +00:00
quadrants-orientation-7.png Replace bild imaging library with boxes-ltd/imaging (#36261) 2026-05-11 12:56:51 +00:00
quadrants-orientation-8.png Fix EXIF profile picture orientation bug (#34275) (#35594) 2026-03-19 15:46:21 +00:00
right-mirrored.jpg [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
right-mirrored.png [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
right-mirrored.tiff [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
right-mirrored.webp [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
right.jpg [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
right.png [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
right.tiff [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
right.webp [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
up-mirrored.jpg [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
up-mirrored.png [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
up-mirrored.tiff [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
up-mirrored.webp [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
up.jpg [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
up.png [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
up.tiff [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00
up.webp [MM-63436] Replace Exif parser dependency (#30479) 2025-04-01 13:57:43 -06:00