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

Imagick errors when reading ARW image from buffer #305

Closed enricoribelli closed 6 months ago

enricoribelli commented 6 months ago

hello team, I am trying to download an image from a URL, hence I have a []byte available in memory. From there I try:

mw := imagick.NewMagickWand()
err := mw.ReadImageBlob(buffer)

Reading the image errors out with ERROR_CODER (450), description: "TIFF directory is missing required \"ImageLength\" field.MissingRequired' @ error/tiff.c/TIFFErrors/599"`. By reading around this is an error from the underlying ImageMagick itself which cannot understand which format is the image and falls back at guessing it's a TIFF, which is not. The code works fine when I load the same ARW image from file but I guess it doesn't have a way to identify it's an ARW when it reads it from a buffer. How do I achieve this? Thanks in advance!

justinfx commented 6 months ago

Try using mw.SetFormat() or mw.SetFilename() before your call to mw.ReadImageBlob() to tell the wand what format to expect the bytes

enricoribelli commented 6 months ago

@justinfx That did the trick! Thank you very much for the prompt reply!