GithubHelp home page GithubHelp logo

gotson / nightmonkeys Goto Github PK

View Code? Open in Web Editor NEW
41.0 4.0 0.0 7.7 MB

Additional plug-ins and extensions for Java's ImageIO using native libraries

License: MIT License

Java 100.00%
java jpeg-xl jxl imageio plugins java-imageio webp avif heif

nightmonkeys's People

Contributors

dependabot[bot] avatar github-actions[bot] avatar gotson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

nightmonkeys's Issues

Java 20 "Missing Foreign Linker API"

I tried to run komga with java 20, and I got this error:

2023-05-14 14:08:04.296  WARN 502417 --- [           main] c.g.g.n.j.i.plugins.JxlImageReaderSpi    : Missing Foreign Linker API, plugin will be disabled. Try adding JVM arguments: --enable-preview

I'm already using this option and everything works correctly with java 19.
This is how I launch komga:

~ $ cat /bin/komga
#!/bin/sh
exec /usr/bin/java --enable-preview -Dforeign.restricted=permit -jar '/usr/share/java/komga/komga.jar' "$@"

Am I doing something wrong?
I tried to search the web, but google can't even find one page with "Missing Foreign Linker API".

Off-Heap native memory leak

I am experiencing an off-heap memory leak in my test application.
When reading many images, Heap size stays well below the max heap configured for the Application (for example 4GB), but when processing many HEIF images, java commit size grows into the tens of GBs of memory. The JVM dies after a while, because it cannot allocate more memory, as well as other applications on the PC due to memory starvation of the whole system.

imageio-common-0.6.2
imageio-heif-0.6.2
imageio-core-3.10.1
libheif 1.14
OpenJDK 21.0.3.9-hotspot

It is easy to reproduce with this test program:

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.imageio.stream.ImageInputStream;

import com.github.gotson.nightmonkeys.heif.imageio.plugins.HeifImageReader;
import com.github.gotson.nightmonkeys.heif.imageio.plugins.HeifImageReaderSpi;

public class HEIFReadLoop {

	private HeifImageReaderSpi heifSpi = new HeifImageReaderSpi();
	private HeifImageReader reader;

	public static void main(String[] args) {
		HEIFReadLoop l = new HEIFReadLoop();
	}

	public HEIFReadLoop() {
		try {
			reader = (HeifImageReader) heifSpi.createReaderInstance();
			int counter = 0;
			while (true) {
				System.out.println("read image " + counter++);
				BufferedImage image = readHeicImage(new File("test.heic"));
			}
		} catch (IOException e) {
			e.printStackTrace();
			return;
		}
	}

	private BufferedImage readHeicImage(File file) throws IOException {
		try (ImageInputStream input = ImageIO.createImageInputStream(file)) {
			reader.reset();
			reader.setInput(input);
			BufferedImage result = reader.read(0);
			reader.dispose();
			return result;
		}
	}

}

Run with -Xmx256m given a sufficiently small .heic image.
When you run this test app, Heap size stays well below 256m for a small image.
But system memory used by the java process grows by about 150m each second, untill all available system RAM is consumed.

Thank you, and a question

First of all, this is a really awesome project: using the new Java 18 Foreign Linker API(instead of JNA) and adding support for JPEG XL to the normal Java ImageIO, meaning using/adopting this lib is really easy to do. You might want to make a post on r/Java to get some more people looking into it.

To the question, are there any plans/roadblocks/ETA for adding writing xlr files? Looking at komga, it's probably the end goal to be able to also read in png files and send them to the client in jxr to save bandwidth on mobile devices.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.