You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+4Lines changed: 4 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,10 @@ library is already used by some larger businesses (which is cool!), and I care a
15
15
Please discuss any bigger changes with me **before** submitting a Pull Request - I can help you refine your idea better
16
16
that way, and I don't want to waste anybody's time: [Discussions](https://github.com/lopcode/vips-ffm/discussions).
17
17
18
+
As part of a pull request I will probably edit commits on the branch, and will squash them down, but will be careful to
19
+
retain your contributor metadata so you're named appropriately as a contributor on GitHub. GitHub Actions workflows to
20
+
run the project's tests require approval - I'll do this when I'm reviewing the PR.
21
+
18
22
I haven't currently defined a code of conduct for this project specifically, but please refer to the CoC [in libvips](https://github.com/libvips/libvips/blob/master/CODE_OF_CONDUCT.md)
Copy file name to clipboardExpand all lines: README.md
+58-3Lines changed: 58 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,8 @@ Fast, safe, complete [libvips](https://github.com/libvips/libvips) bindings for
4
4
5
5
Supports a vast range of image formats, including HEIC, JXL, WebP, PNG, JPEG, and more. Pronounced "vips (like zips)
6
6
eff-eff-emm". The project is relatively new, but aims to be production ready. Tested on macOS 14, Windows 11, and Linux
7
-
(Ubuntu 24.04, Debian 12.1). Should work on any architecture you can use libvips and Java on (arm64/amd64/etc).
7
+
(Ubuntu 24.04, Debian 12.1, with and without jemalloc). Should work on any architecture you can use libvips and
8
+
Java on (arm64/amd64/etc).
8
9
9
10
Uses the "Foreign Function & Memory API" ([JEP 454](https://openjdk.org/jeps/454)), and the "Class-File API" ([JEP 457](https://openjdk.org/jeps/457)) released in JDK 22.
10
11
Built in such a way that it's usually the fastest image processing library available for Java.
// Call once to initialise libvips when your program starts, from any thread
59
60
// Note that by default this blocks untrusted operations (like loading PDFs)
60
-
//Use `Vips.init(true, ...)` to permit untrusted operations
61
+
//See the "Allowing untrusted operations" section below to read about permitting untrusted operations
61
62
Vips.init()
62
63
63
64
// Use `Vips.run` to wrap your usage of the API, and get an arena with an appropriate lifetime to use
@@ -193,6 +194,60 @@ like Android where it's hard to set the system library path), you can do so usin
193
194
* glib: `vipsffm.libpath.glib.override`
194
195
* gobject: `vipsffm.libpath.gobject.override`
195
196
197
+
## Operationalisation
198
+
199
+
libvips maintain [a checklist](https://www.libvips.org/API/8.17/developer-checklist.html) of things to be aware of when
200
+
using the library. Of particular note for vips-ffm is memory usage - especially if the library is used for long-running
201
+
application (like a server).
202
+
203
+
### Operation cache
204
+
205
+
At the time of writing, libvips maintains a cache of the 100 most recent operations ([see docs](https://www.libvips.org/API/8.17/how-it-works.html#operation-cache)).
206
+
If running an image proxy, or something that processes lots of different images, you won't see any benefit, and can
207
+
disable it:
208
+
209
+
```java
210
+
Vips.init();
211
+
Vips.disableOperationCache();
212
+
```
213
+
214
+
### Memory allocation
215
+
216
+
On glibc-based Linux systems (e.g. Debian, Red Hat), the default memory allocator performs poorly for long-running,
217
+
multithreaded processes with frequent small allocations. Using an alternative allocator like jemalloc can reduce the
218
+
off-heap footprint of the JVM when using libvips.
219
+
220
+
Note that the jemalloc project is going through [some turbulence](https://jasone.github.io/2025/06/12/jemalloc-postmortem/)
221
+
at the moment. Facebook have [forked it](https://github.com/facebook/jemalloc), though its maintenance status is
222
+
currently unknown.
223
+
224
+
An example of using jemalloc on Ubuntu:
225
+
1. Install jemalloc
226
+
```sh
227
+
apt install libjemalloc2
228
+
```
229
+
2. Set the `LD_PRELOAD` environment variable before running your application.
230
+
```sh
231
+
ln -sT "$(readlink -e /usr/lib/*/libjemalloc.so.2)" /usr/local/lib/libjemalloc.so # symlink jemalloc to a standard location
232
+
export LD_PRELOAD=/usr/local/lib/libjemalloc.so
233
+
java -jar ...
234
+
```
235
+
236
+
### Allowing untrusted operations
237
+
238
+
By default, vips-ffm sets the "block untrusted operations" flag in libvips, in an attempt to be "secure by default".
239
+
This includes blocking things like the imagemagick and PDF loaders. If you get an error relating to "operation is
240
+
blocked", then the operation you're trying to use is marked as untrusted in libvips.
241
+
242
+
If you need to work with operations and formats that are marked as "untrusted" in libvips, you can permit them
243
+
explicitly:
244
+
```java
245
+
Vips.allowUntrustedOperations();
246
+
```
247
+
248
+
See the [libvips docs](https://www.libvips.org/API/8.17/func.block_untrusted_set.html) for guidance on figuring out what
249
+
loaders and operations are marked as trusted or untrusted.
250
+
196
251
## Project goals
197
252
198
253
Ideas and suggestions are welcome, but please make sure they fit in to these goals, or you have a good argument about
@@ -224,4 +279,4 @@ Thank you for being enthusiastic about the project!
224
279
* And only after a GitHub Release is made
225
280
* Run `./publish_release_to_maven_central.sh <version matching github release version, including v prefix>`
0 commit comments