Closed negator closed 1 year ago
ping @AttilaTheFun
Hey @negator ! I've contributed to the repo previously but I don't have permission to merge PRs. cc @tonimelisma @davidbyttow
This looks great! Give me a day to get back to this and respond.
I'd love to see more tests added, but will merge.
noticed BMP failure with "not supported", not sure if related?
Interesting, let me take a look and get back you.
@davidbyttow I added several more tests to ensure all image types can be read and written. As well as updated the golden tests to ensure exporting to writers works correctly.
Some things I discovered:
vips-8.14.3
). And there isn't really a good way to determine if a writer is closed (or becomes closed) prior to writing to it. We can exclude these files from streaming writes if it seems prudent. (segfault appears to be inherent to this function).I discovered that there are severe performance penalties that are incurred when C code calls Go code, which this implementation requires. Especially since it performs many 100s of C-to-Go calls from both the reader and writer. I don't really feel comfortable merging this as-is since it might affect performance for the users of the NewImageFromReader function. Additionally the ExportWriter functions will incur similar performance issues.
However I believe there will be a performance boost for users of the NewImageFromFile function which leverages the input streaming capability of libvips from files (incurring no C to Go overhead). Replacing the ExportWriter functions with functions that export to files will similarly yield a more performant implementation.
For now I'd like to close this PR and potentially reopen one with the above mentioned updates at a later time. Let me know how your like to proceed.
@negator Thank you so much for looking into this! It's very disappointing to hear about the C-to-Go issue.
Adds Source and Target for full streaming support.
https://www.libvips.org/2019/11/29/True-streaming-for-libvips.html
This is a fairly straightforward patch. We add two new functions
NewSourceFromReader
andNewTargetToWriter
, along with anExportWriter
function and all secondaryExport[Jpeg|Tiff...]Target
functions.Inspired by: https://github.com/vansante/go-vips-thumbnailer
cc @tonimelisma