imagick
imagick copied to clipboard
Issue: MontageImage returning nil MagickWand obj
Using 7.0.9-8 for ImageMagick 9.52 Gslib and 3.30 for golang imagegick
`
imagick.Initialize()
defer imagick.Terminate()
mwResult := imagick.NewMagickWand()
defer mwResult.Destroy()
mw := imagick.NewMagickWand()
defer mw.Clear()
err := mw.SetResolution(150, 150)
if err != nil {
return nil, err
}
dw := imagick.NewDrawingWand()
defer dw.Clear()
mon := imagick.NewMagickWand()
defer mon.Clear()
err = mon.SetResourceLimit(imagick.RESOURCE_MEMORY, 8589934592)
if err != nil {
return nil, err
}
err = mon.SetResourceLimit(imagick.RESOURCE_MAP, 8589934592)
if err != nil {
return nil, err
}
data, err := ioutil.ReadFile(localPDFFilePath)
if err != nil {
return nil, err
}
zerologger.Info().Msg("ReadImageBlob started")
err = mw.ReadImageBlob(data)
if err != nil {
return nil, err
}
zerologger.Info().Msg("ReadImageBlob completed")
zerologger.Info().Msg("MontageImage started")
mon = mw.MontageImage(dw, "4x4+0+0", "640x480+0+0", imagick.MONTAGE_MODE_UNFRAME, "0x0+0+0")
zerologger.Info().Msg("MontageImage completed")
dw.Clear()
mw.Clear()
//HERE: ERR: mon obj has nil 'mw' object, and causing issue
err = mon.SharpenImage(2, 1)
if err != nil {
return nil, err
}
err = mon.SetImageFormat("pdf")
if err != nil {
return nil, err
}
err = mwResult.AddImage(mon)
if err != nil {
return nil, err
}
zerologger.Info().Msg("GetImagesBlob started")
result := mwResult.GetImagesBlob()
zerologger.Info().Msg("GetImagesBlob completed")
return result, nil`
It returns Assertion Failed error after
Assertion failed: wand != (MagickWand *) NULL,file ../ImageMagick-7.0.9-2/MagickWand/magick-image.c, line 11467
This issue only comes if we pass large PDF file which contains more than 300+ pages depends on content of page.
Maybe you can check if the original wand had an error with mw.GetLastError()? If it only happens with certain sizes of PDF then it might be related to ghostscript or C Imagemagick. The Go bindings wouldn't do anything different depending on the PDF
Thank you, It was low disk space issue, and mw.MontageImage() don't have any error return, so that's why this issue wasn't caught, but thank you for letting me know about. mw.GetLastError().
Oh good. Glad this helped you identify the issue. I think that method should return an error as a second return argument.
On Fri, May 15, 2020, 10:18 PM Shahzada Saleem [email protected] wrote:
Thank you, It was low disk space issue, and mw.MontageImage() don't have any error return, so that's why this issue wasn't caught, but thank you for letting me know about. mw.GetLastError().
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/gographics/imagick/issues/236#issuecomment-629155615, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACE7RU5VKBMGLU2FIA56ZTRRUJI5ANCNFSM4NA2YAIA .