Skip to content

Commit

Permalink
Add spec file for interpolate
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandlo committed Mar 20, 2024
1 parent 730a737 commit c95f5d1
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions spec/interpolate_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
local vips = require "vips"

-- test image interpolation
describe("image interpolation", function()
setup(function()
-- vips.log.enable(true)
end)

it("can rotate an image using nearest interpolator", function()
local interpolate = vips.Interpolate.new_from_name("nearest")
local original = {
{ 1, 2, 3 },
{ 4, 5, 6 },
{ 7, 8, 9 },
}
local rotated = {
{ 0.0, 0.0, 1.0, 0.0 },
{ 0.0, 0.0, 1.0, 2.0 },
{ 0.0, 7.0, 5.0, 3.0 },
{ 0.0, 8.0, 9.0, 6.0 }
}
local im = vips.Image.new_from_array(original)
local rot = im:rotate(45, { interpolate = interpolate })
assert.are.equal(rot:width(), 4)
assert.are.equal(rot:height(), 4)
assert.are.equal(rot:bands(), 1)
for x = 1, 4 do
for y = 1, 4 do
assert.are_equal(rot(x - 1, y - 1), rotated[y][x])
end
end
end)
end)

0 comments on commit c95f5d1

Please sign in to comment.