imagick icon indicating copy to clipboard operation
imagick copied to clipboard

Whether to make GetImageBlob() report error

Open Zstro opened this issue 3 years ago • 5 comments

  • version of imageMagick:
    Version: ImageMagick 7.0.9-13 Q16 x86_64 2020-01-01 https://imagemagick.org
    Copyright: © 1999-2020 ImageMagick Studio LLC
    License: https://imagemagick.org/script/license.php
    Features: Cipher DPC HDRI
    Delegates (built-in): bzlib fontconfig freetype jng jpeg lzma pangocairo png tiff webp wmf x xml zlib
    
  • imagick version: gopkg.in/gographics/imagick.v3 v3.3.0

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

Zstro avatar Oct 26 '22 07:10 Zstro

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:

  • Update the documentation to recommend checking if the bytes are empty, and checking GetLastError
  • Add a new variation like GetImageBlobErr() []byte, error
  • Just make the breaking change, release as a new minor version, and let users update their code when it breaks

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?

justinfx avatar Oct 26 '22 07:10 justinfx

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

Zstro avatar Oct 31 '22 08:10 Zstro

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 avatar Oct 31 '22 09:10 justinfx

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

Zstro avatar Nov 01 '22 02:11 Zstro

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.

justinfx avatar Jul 14 '23 21:07 justinfx