gographics / imagick

Go binding to ImageMagick's MagickWand C API
https://godoc.org/github.com/gographics/imagick/imagick
Other
1.75k stars 182 forks source link

Whether to make GetImageBlob() report error #284

Closed Zstro closed 3 months ago

Zstro commented 1 year ago

i find some question when debugging.

q1, as shown in the figure, ImageMagick report error when GetImageBlob(). i think GetImageBlob() should report it.

image

q2, i got error convert: partition 0 overflow (> 512K) from convert and got nothing with GetImageBlob(). image

justinfx commented 1 year ago

It is a shame that GetImageBlob and GetImagesBlob don't check for an error and return an extra error value. If we changed that now, it would be a breaking api change. So we have a few options:

For your second question, I am not sure where that error is supposed to be generated from the ImageMagick api. If you check GetLastError immediately after the call to GetImageBlob does it produce the expected webp error? Would fixing your first question also fix the second?

Zstro commented 1 year ago

I'm sorry for not recovering in time, interrupted by other things. For q2, i think it should error in setImageFormat, but i caught error in goroutine after executing GetImageBlob(), and the main func couldn't exec in order. image

justinfx commented 1 year ago

I don't fully understand you last example. Why are you trying to catch the error in a tight loop in a goroutine instead of just checking GetLastError after your call to GetImageBlob? You seem to just move on to the next call.
My point was asking whether you can get the error with GetLastError right after GetImageBlob

Zstro commented 1 year ago

I can't get error after GetImageBlob, func was interrupted without any result.

I don't fully understand you last example. Why are you trying to catch the error in a tight loop in a goroutine instead of just checking GetLastError after your call to GetImageBlob? You seem to just move on to the next call. My point was asking whether you can get the error with GetLastError right after GetImageBlob

justinfx commented 1 year ago

If you can provide a reproduction of this error (code and source image) then I will look at improving the error handling. Otherwise this ticket might be closed.