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

Issue: MontageImage returning nil MagickWand obj #236

Open
asaleem772 opened this issue May 14, 2020 · 3 comments
Open

Issue: MontageImage returning nil MagickWand obj #236

asaleem772 opened this issue May 14, 2020 · 3 comments
Labels

Comments

@asaleem772
Copy link

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.

@justinfx
Copy link
Member

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

@asaleem772
Copy link
Author

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().

@justinfx
Copy link
Member

justinfx commented May 15, 2020 via email

@justinfx justinfx added the bug label Dec 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants