Skip to content
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

Whether to make GetImageBlob() report error #284

Closed
Zstro opened this issue Oct 26, 2022 · 5 comments
Closed

Whether to make GetImageBlob() report error #284

Zstro opened this issue Oct 26, 2022 · 5 comments

Comments

@Zstro
Copy link

Zstro commented Oct 26, 2022

  • 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

@justinfx
Copy link
Member

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?

@Zstro
Copy link
Author

Zstro commented Oct 31, 2022

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
Copy link
Member

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
Copy link
Author

Zstro commented Nov 1, 2022

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
Copy link
Member

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 justinfx closed this as not planned Won't fix, can't repro, duplicate, stale May 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants