-
Notifications
You must be signed in to change notification settings - Fork 206
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unexpected behaviour on loading truncated images #147
Comments
Hey @bozaro thanks for this. There is already a more generic PR being worked on here: #111 The idea is to create a similar ImportParams struct and associated functions as we have for ExportParams, and a new Import function in addition to the current one which would also accept the ImportParams parameter. Seeing as there hasn't been any action on the PR if you have the energy to create a similar PR that would be hugely appreciated. The specs on how to approach this are all described in the PR discussions. Do you think you this would be too much work? |
I create PoC for |
Hey @bozaro is the fail parameter now probably handled with the new import parameters? Can we close the issue? |
This issue was fixed by #166 and can be closed. |
Now call
NewImageFromBuffer
for truncatedjpeg
andpng
load successfully and produce some warning. It was unexpected for me.Warnings are useless in this case: in a multithreaded application, they cannot be associated with a specific function call. I expected an error like
io.ErrUnexpectedEOF
.This behavior can be controlled through the flag
"fail"
(with the exception of libvips/libvips#1946).For example:
I admit the current behavior might be helpful. And the value of the
"fail"
flag should be controlled by the user.I see the following solutions to the problem:
LoadingOptions
parameter likefunc NewImageFromBuffer(buf []byte, opts *LoadingOptions) (*ImageRef, error) {
(but this is breaking change);LoadingOptions
parameter likefunc NewImageFromBuffer(buf []byte, opts ...LoadingOptions) (*ImageRef, error) {
withMergeLoadingOptions
method like https://github.com/mongodb/mongo-go-driver/blob/master/mongo/options/dboptions.go (but this is minor breaking change);fail
flag (but this is ugly solution, especially in a multi-threaded application).I would like to know which path is preferable before submitting the PR with changes.
P. S. https://twitter.com/kernio/status/879944532808278016
The text was updated successfully, but these errors were encountered: