Skip to content

Commit b2cfeb6

Browse files
committed
Update README
1 parent bb646b9 commit b2cfeb6

File tree

1 file changed

+70
-13
lines changed

1 file changed

+70
-13
lines changed

README.md

Lines changed: 70 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33
[![CI](https://github.com/libvips/lua-vips/workflows/CI/badge.svg)](https://github.com/libvips/lua-vips/actions)
44

55
This is a Lua binding for the [libvips image processing
6-
library](http://libvips.github.io/libvips). libvips
7-
is a [fast image processing library with low memory
8-
needs](https://github.com/jcupitt/lua-vips-bench). `lua-vips` uses ffi
9-
and needs luajit 2.0 or later.
6+
library](http://libvips.github.io/libvips). `libvips`
7+
is a [fast image processing library with low memory needs](https://github.com/jcupitt/lua-vips-bench).
8+
`lua-vips` uses ffi and needs either
9+
- luajit >= 2.0 or
10+
- standard Lua (5.1 up to 5.4) combined with the [`luaffi-tkl`](https://luarocks.org/modules/sudheerhebbale/luaffi-tkl) Lua package.
1011

11-
The libvips documentation includes a
12-
handy searchable table of [every operation in
12+
On the x64 architecture `lua-vips` is continuously tested
13+
- on Linux and MacOS with Lua 5.1, 5.2, 5.3, 5.4, luajit and openresty-luajit
14+
- on Windows using [MSYS2 MinGW-w64](https://www.msys2.org/) with Lua 5.3, 5.4 and luajit
15+
16+
`lua-vips` should work on arm64 (recently tested on a Pinephone Pro using PostmarketOS) and possibly x86 (currently untested)
17+
as well.
18+
19+
The libvips documentation includes a handy searchable table of [every operation in
1320
libvips](http://libvips.github.io/libvips/API/current/func-list.html). This
1421
is a good place to check if it supports some feature you need. Read on to
1522
see how to call libvips operations.
@@ -23,6 +30,11 @@ library](https://libvips.github.io/libvips/install.html), then install this rock
2330
luarocks install lua-vips
2431
```
2532

33+
When used with LuaJIT please first exhibit luaffi-tkl as provided by the VM via:
34+
```shell
35+
luarocks config --lua-version=5.1 rocks_provided.luaffi-tkl 2.1-1
36+
```
37+
2638
Example:
2739

2840
```lua
@@ -214,15 +226,13 @@ local data = ffi.new("unsigned char[?]", width * height)
214226
local im = vips.Image.new_from_memory(data, width, height, 1, "uchar")
215227
```
216228

217-
The returned image is using a pointer to the `data` area, but luajit won't
218-
always know this. You should keep a reference to `data` alive for as long as you
219-
are using any downstream images, or you'll get a crash.
229+
The returned image is using a pointer to the `data` area, but the Lua/LuaJIT interpreter won't always know this. You should keep a reference to `data` alive for as long as you are using any downstream images, or you'll get a crash.
220230

221231
### `image = vips.Image.new_from_memory_ptr(data, size, width, height, bands, format)`
222232

223233
Same as `new_from_memory`, but for any kind of data pointer (non-FFI allocated) by specifying the length of the data in bytes. The pointed data must be valid for the lifespan of the image and any downstream images.
224234

225-
A string can be used as the data pointer thanks to LuaJIT FFI semantics.
235+
A string can be used as the data pointer thanks to FFI semantics.
226236

227237
### `image = vips.Image.new_from_image(image, pixel)`
228238

@@ -555,7 +565,7 @@ vips.cache_set_max_files(10)
555565

556566
# Development
557567

558-
### Setup for ubuntu 17.04
568+
### Setup for Ubuntu
559569

560570
Configure `luarocks` for a local tree
561571

@@ -619,7 +629,7 @@ luacheck .
619629
Run the example script with:
620630

621631
```shell
622-
luajit example/hello-world.lua
632+
lua example/hello-world.lua
623633
```
624634

625635
### Update rock
@@ -639,9 +649,56 @@ https://github.com/luarocks/luarocks/wiki/creating-a-rock
639649

640650
https://olivinelabs.com/busted/
641651

652+
### Running on Windows using Mingw-w64
653+
654+
Installing `lua-vips` on Windows is a bit harder than on Unix systems. We recommend using MinGW (Minimalist GNU for Windows) for the installation. Here are the steps:
655+
656+
1. Install [MSYS2](https://www.msys2.org/) to the default path.
657+
2. Start Mingw-w64 64bit console from the start menu. Check that is says MINGW64. The following steps happen in that console.
658+
3. Update MSYS2 using
659+
```shell
660+
pacman -Syuu
661+
```
662+
4. Install the build tools (including Lua 5.4 and Luarocks) via
663+
```shell
664+
pacman -S git make mingw-w64-x86_64-toolchain mingw-w64-x86_64-lua-luarocks
665+
```
666+
5. Install `libvips` with (optional) dependencies via
667+
```shell
668+
pacman -S
669+
mingw-w64-x86_64-libvips
670+
mingw-w64-x86_64-openslide
671+
mingw-w64-x86_64-libheif
672+
mingw-w64-x86_64-libjxl
673+
mingw-w64-x86_64-imagemagick
674+
mingw-w64-x86_64-poppler
675+
```
676+
6. Optionally: If you want to use `lua-vips` with LuaJIT instead of Lua 5.4 install LuaJIT via
677+
```shell
678+
pacman -S mingw-w64-x86_64-luajit
679+
luarocks config --scope system lua_version 5.1
680+
luarocks config --scope system lua_interpreter luajit.exe
681+
luarocks config --scope system variables.LUA_DIR /mingw64/bin
682+
luarocks config --scope system variables.LUA_INCDIR /mingw64/include/luajit-2.1/
683+
luarocks config --scope system rocks_provided.luaffi-tkl 2.1-1
684+
```
685+
7. Install `lua-vips` via
686+
```shell
687+
luarocks install lua-vips
688+
```
689+
or clone the repository and run `luarocks make` in the `lua-vips` folder.
690+
8. Add `C:\msys64\mingw64\bin` and `C:\msys64\usr\bin` to the top of your `PATH`
691+
environment variable in the Windows Advanced system settings and restart the console.
692+
693+
9. Run `lua` or `luajit` and try
694+
```lua
695+
vips = require "vips"
696+
print(vips.Image.xyz(3,2))
697+
```
698+
642699
### Running under Wine (Windows emulation on Linux)
643700

644-
I used the luapower all-in-one to get a 64-bit Windows LuaJIT build:
701+
@jcupitt used the luapower all-in-one to get a 64-bit Windows LuaJIT build:
645702

646703
https://luapower.com/
647704

0 commit comments

Comments
 (0)