JVips
JVips copied to clipboard
Support for demand-driven write
Hi,
Nice wrapper, thanks!
Looks like I need some help with understanding "[demand-driven feature]( https://github.com/libvips/libvips/wiki/Why-is-libvips-quick)
".
As far as I understand libvips can process image without loading it to RAM fully.
For Jvips it is possible to pass MappedByteBuffer as input; But how about output?
Does it mean JVips doesn't support this feature or I missed the point of "demand-driven" and it applies only for reading.
Thanks. B.
Yes, from my understanding, JVips doesn't support it, but it would be a nice improvement.
@dbouron Can you confirm?
Yes, we didn't implement it because when we measured cpu performance between mapped and byte array, the results were very similar. Thus, we decided to keep a straightforward implementation for our app. We didn't measure the impact on the memory, it would be a nice to have. If we implement this feature, we must provide benchmark on the memory consumption.
thanks! btw, here the small snippet how I test JVips Read
try (FileChannel ch = Files.newByteChannel(path, READ);
VipsImage image = new VipsImage(ch.map(READ_ONLY, 0, ch.size()), (int) ch.size())) {
...
}
Write
try (FileChannel ch = Files.newByteChannel(path, WRITE)) {
os.write(ByteBuffer.wrap(img.writeToArray(VipsImageFormat.JPG, true)));
}