Skip to content

Commit 1bc305d

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

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

spec/connection_spec.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
local tmpdir, svg, jpeg, webp, tempfile
8+
9+
setup(function()
10+
-- vips.log.enable(true)
11+
end)
12+
13+
describe("to file target", function()
14+
it("can create image from file source and write to file target", function()
15+
local source = vips.Source.new_from_file(JPEG_FILE)
16+
local image = vips.Image.new_from_source(source, '', { access = 'sequential' })
17+
local filename = ffi.os == "Windows" and os.getenv("TMP") .. "\\x.png" or "/tmp/x.png"
18+
local target = vips.Target.new_to_file(filename)
19+
image:write_to_target(target, '.png')
20+
21+
local image1 = vips.Image.new_from_file(JPEG_FILE, { access = 'sequential' })
22+
local image2 = vips.Image.new_from_file(filename, { access = 'sequential' })
23+
assert.is_true((image1 - image2):abs():max() < 10)
24+
end)
25+
end)
26+
end)

0 commit comments

Comments
 (0)