imgA-ops: ops/ImageOps (convert between every pixel format incl. yuv420p, crop, resize nearest/bilinear/Lanczos-3 as Pillow, flip, rotate90, rotate bilinear+expand as Pillow, blit/composite with Pillow's alpha_composite, premultiply, get/setPixel, fill, coalesce/fromFrames/frameCount/durations) with Pillow fixtures, tests on both runtimes, bench block

This commit is contained in:
4DBug committed 2026-10-31 08:47:30 -05:00
1 parent 2eee0bc1a6
commit e2b338db7e
5 files changed
+1624

No files matched your search

+29
View File
@@ -56,3 +56,32 @@ do
Png.encode(img)
end)
end
-- ------------------------------------------------------------------------------------------------ ops/ImageOps
do
local Ops = require("@formats/ops/ImageOps")
local img = assert(Png.decode(Bytes.reader(buffer.fromstring(PB[1].data))))
local n = img.width * img.height * 4
bench("imageops resize 1/2 bilinear", 2, n, function()
Ops.resize(img, img.width // 2, img.height // 2, "bilinear")
end)
bench("imageops resize 1/2 lanczos", 2, n, function()
Ops.resize(img, img.width // 2, img.height // 2, "lanczos")
end)
bench("imageops resize x1.5 bilinear", 1, n, function()
Ops.resize(img, img.width * 3 // 2, img.height * 3 // 2, "bilinear")
end)
bench("imageops rotate 30 (expand)", 1, n, function()
Ops.rotate(img, 30)
end)
bench("imageops rotate90", 3, n, function()
Ops.rotate90(img, 1)
end)
bench("imageops convert rgba8 -> gray8", 3, n, function()
Ops.convert(img, "gray8")
end)
local other = assert(Ops.flip(img, "h"))
bench("imageops composite over", 3, n, function()
Ops.composite(img, other)
end)
end