Skip to content

Commit 0895fd2

Browse files
committed
Add test for file source and target
1 parent f3be0e3 commit 0895fd2

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

spec/connection_spec.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
local vips = require "vips"
2+
local ffi = require "ffi"
3+
4+
local JPEG_FILE = "./spec/images/Gugg_coloured.jpg"
5+
-- test gvalue
6+
describe("test connection", function()
7+
8+
setup(function()
9+
-- vips.log.enable(true)
10+
end)
11+
12+
describe("to file target", function()
13+
it("can create image from file source and write to file target", function()
14+
local source = vips.Source.new_from_file(JPEG_FILE)
15+
local image = vips.Image.new_from_source(source, '', { access = 'sequential' })
16+
local filename = ffi.os == "Windows" and os.getenv("TMP") .. "\\x.png" or "/tmp/x.png"
17+
local target = vips.Target.new_to_file(filename)
18+
image:write_to_target(target, '.png')
19+
20+
local image1 = vips.Image.new_from_file(JPEG_FILE, { access = 'sequential' })
21+
local image2 = vips.Image.new_from_file(filename, { access = 'sequential' })
22+
assert.is_true((image1 - image2):abs():max() < 10)
23+
end)
24+
end)
25+
end)

0 commit comments

Comments
 (0)