File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
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 )
You can’t perform that action at this time.
0 commit comments