Skip to content

Commit

Permalink
Add example for writing to target
Browse files Browse the repository at this point in the history
  • Loading branch information
rolandlo committed Dec 23, 2024
1 parent 7d6cd79 commit 1d34228
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions example/target.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
local vips = require "vips"

if #arg ~= 2 then
error("Usage: lua test.lua ~/pics/k2.png .avif > x")
end

local infilename = arg[1]
local fmt = arg[2]

local descriptor = {
stdin = 0,
stdout = 1,
stderr = 2,
}

local image = vips.Image.new_from_file(infilename)
local target = vips.Target.new_to_descriptor(descriptor.stdout)
image:write_to_target(target, fmt)

0 comments on commit 1d34228

Please sign in to comment.