Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to call VipsForeignLoadPngFile #49

Open
sjkim04 opened this issue Aug 10, 2022 · 5 comments
Open

Unable to call VipsForeignLoadPngFile #49

sjkim04 opened this issue Aug 10, 2022 · 5 comments

Comments

@sjkim04
Copy link

sjkim04 commented Aug 10, 2022

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.

@jcupitt
Copy link
Member

jcupitt commented Aug 10, 2022

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
> 

@sjkim04
Copy link
Author

sjkim04 commented Aug 10, 2022

$ 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.

@jcupitt
Copy link
Member

jcupitt commented Aug 11, 2022

I'll see if I can make a dockerfile that reproduces this.

@jcupitt
Copy link
Member

jcupitt commented Aug 11, 2022

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.

@jcupitt
Copy link
Member

jcupitt commented Aug 11, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants