Skip to content

Commit 1d34228

Browse files
committed
Add example for writing to target
1 parent 7d6cd79 commit 1d34228

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

example/target.lua

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
local vips = require "vips"
2+
3+
if #arg ~= 2 then
4+
error("Usage: lua test.lua ~/pics/k2.png .avif > x")
5+
end
6+
7+
local infilename = arg[1]
8+
local fmt = arg[2]
9+
10+
local descriptor = {
11+
stdin = 0,
12+
stdout = 1,
13+
stderr = 2,
14+
}
15+
16+
local image = vips.Image.new_from_file(infilename)
17+
local target = vips.Target.new_to_descriptor(descriptor.stdout)
18+
image:write_to_target(target, fmt)

0 commit comments

Comments
 (0)