lua-vips
lua-vips copied to clipboard
Unable to call VipsForeignLoadPngFile
I'm tampering with lua-vips on a Raspberry Pi with a custom-built libvips, and I can't seem to get the module to work.
Here's the simple code I used:
local vips = require "vips"
local base = vips.Image.new_from_file("base.png")
and here's the traceback (run with luvit):
$ luvit test.lua
Uncaught exception:
./vips/voperation.lua:216: unable to call VipsForeignLoadPngFile
stack traceback:
[C]: in function 'error'
./vips/voperation.lua:216: in function 'new_from_file'
/home/sjkim04/Desktop/test.lua:2: in function 'fn'
[string "bundle:deps/require.lua"]:310: in function 'require'
[string "bundle:/main.lua"]:128: in function <[string "bundle:/main.lua"]:20>
stack traceback:
[C]: in function 'error'
[string "bundle:/deps/utils.lua"]:41: in function 'assertResume'
[string "bundle:/init.lua"]:52: in function <[string "bundle:/init.lua"]:47>
[C]: in function 'xpcall'
[string "bundle:/init.lua"]:47: in function 'fn'
[string "bundle:deps/require.lua"]:310: in function <[string "bundle:deps/require.lua"]:266>
What's the problem with this? I installed most of the optional dependencies, including libspng, and the code still fails. I would appreciate some help.
Hi @sjkim04,
I suppose I would first try to verify that your libvips is working. You can do:
$ vips --vips-config | grep -i png
PNG load/save with libspng: false
PNG load/save with libpng: true
To check that it picked up libspng (or libpng, for me) correctly. Then maybe:
$ vipsheader ~/pics/k2.png
/home/john/pics/k2.png: 1450x2048 uchar, 3 bands, srgb, pngload
To make sure it can call it.
I see:
$ luajit
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/
JIT: ON SSE2 SSE3 SSE4.1 AMD BMI2 fold cse dce fwd dse narrow loop abc sink fuse
> vips = require "vips"
> base = vips.Image.new_from_file("k2.png")
> print(base:width())
1450
>
$ vips --vips-config | grep -i png
memory: high-water mark 0 bytes
PNG load with libspng: true
PNG load/save with libpng: false
$ vipsheader ./base.png
./base.png: 1280x720 uchar, 4 bands, srgb, pngload
memory: high-water mark 0 bytes
$ luajit
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/
JIT: ON fold cse dce fwd dse narrow loop abc sink fuse
> vips = require "vips"
> base = vips.Image.new_from_file("base.png")
./vips/voperation.lua:216: unable to call VipsForeignLoadPngFile
stack traceback:
[C]: in function 'error'
./vips/voperation.lua:216: in function 'new_from_file'
stdin:1: in main chunk
[C]: at 0xaaaadcb40994
>
So it's not vips' problem, as far as I can tell from your comment. What could it be? One thing I can expect is the environment (I didn't install any of the Lua development packages). If that matters, I'll try to fix it.
Edit: As I said, I am running this on a Raspberry Pi 4, running Ubuntu 21.04 LTS (ARM64). Just thought I'd tell you this.
I'll see if I can make a dockerfile that reproduces this.
I had a quick go:
https://github.com/jcupitt/docker-builds/blob/master/lua-vips-ubuntu21.04/Dockerfile
But canonical seem to be having some DNS problems so I can't test it, unfortunately. I might try again later.
Oh, just me being dumb, 21.04 is not an LTS, so it's out of support. Assuming you meant 20.04 I made this:
https://github.com/jcupitt/docker-builds/blob/master/lua-vips-ubuntu20.04/Dockerfile
It seems to work, I see:
$ docker run -it --rm -v $PWD:/data lua-vips-ubuntu20.04
root@b3bf1d41c7c2:/usr/local/src# cd /data/
root@b3bf1d41c7c2:/data# ls
Dockerfile README.md astronauts.png
root@b3bf1d41c7c2:/data# luajit
LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2017 Mike Pall. http://luajit.org/
JIT: ON SSE2 SSE3 SSE4.1 AMD BMI2 fold cse dce fwd dse narrow loop abc sink fuse
> vips = require("vips")
> x = vips.Image.new_from_file("astronauts.png")
> print(x:width())
900
>
Could you test that on your rpi?