imgA: JPEG-in-TIFF pixel check through F.load (image/jpeg via the decodeImage hook) against tifffile

This commit is contained in:
4DBug committed 2026-10-31 08:53:29 -05:00
1 parent f5fa1cb8b0
commit 4ac5d6c3bd
2 files changed
+22 -2

No files matched your search

+13
View File
@@ -89,6 +89,19 @@ do
end,
})
t:check(img and calls > 0, "jpeg through the hook")
-- the real thing through the api (image/jpeg decodes the stitched streams): within 2 levels of libjpeg-turbo
local F = require("@formats")
local ref = Fx.jpegRef
local full, ferr = F.load(Fx.jpeg, { format = "tiff" })
t:check(full and full.width == ref.width and full.height == ref.height, "jpeg-in-tiff through F.load: " .. tostring(ferr))
local worst = 0
for i = 0, ref.width * ref.height - 1 do
for k = 0, 2 do
worst = math.max(worst, math.abs(buffer.readu8(full.pixels, i * 4 + k) - string.byte(ref.rgb, i * 3 + k + 1)))
end
end
t:check(worst <= 2, "jpeg-in-tiff pixels: max error " .. worst .. " against tifffile")
t:note("JPEG-in-TIFF through F.load: max error %d against tifffile / libjpeg-turbo", worst)
end
-- encoder round trips