Skip to content

Commit 51334cc

Browse files
committed
Add spec file for interpolate
1 parent d06996b commit 51334cc

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

spec/interpolate_spec.lua

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
local vips = require "vips"
2+
3+
-- test image interpolation
4+
describe("image interpolation", function()
5+
setup(function()
6+
-- vips.log.enable(true)
7+
end)
8+
9+
it("can rotate an image using nearest interpolator", function()
10+
local interpolate = vips.Interpolate.new_from_name("nearest")
11+
local original = {
12+
{ 1, 2, 3 },
13+
{ 4, 5, 6 },
14+
{ 7, 8, 9 },
15+
}
16+
local rotated = {
17+
{ 0.0, 0.0, 1.0, 0.0 },
18+
{ 0.0, 0.0, 1.0, 2.0 },
19+
{ 0.0, 7.0, 5.0, 3.0 },
20+
{ 0.0, 8.0, 9.0, 6.0 }
21+
}
22+
local im = vips.Image.new_from_array(original)
23+
local rot = im:rotate(45, { interpolate = interpolate })
24+
assert.are.equal(rot:width(), 4)
25+
assert.are.equal(rot:height(), 4)
26+
assert.are.equal(rot:bands(), 1)
27+
for x = 1, 4 do
28+
for y = 1, 4 do
29+
assert.are_equal(rot(x - 1, y - 1), rotated[y][x])
30+
end
31+
end
32+
end)
33+
end)

0 commit comments

Comments
 (0)