This project has moved and is read-only. For the latest updates, please go here.

StackOVerFlowException was Unhandled

Dec 8, 2015 at 11:11 AM
I am new to using MAgick.NET in Visual Studio 2005, I am trying convert a PDF into Tif files for each page using a sample code from Magick.Net web site.

I get this error:
"An unhandled exception of type 'System.StackOverflowException' occurred in Magick.NET.Wrapper-x86.dll "

This happens when using the following sample Code:
Public Sub TestImagicMagick()
    Dim settings As New MagickReadSettings()
    ' Settings the density to 300 dpi will create an image with a better quality
    settings.Density = New PointD(300, 300)

    Using images As New MagickImageCollection()
        ' Add all the pages of the pdf file to the collection
        images.Read("C:\Temp\MyTEST.pdf", settings)

        Dim page As Integer = 1
        For Each image As MagickImage In images
            ' Write page to file that contains the page number
            image.Write("C:\Temp\MyTEST.pdf.Page" & page & ".png")
            'Writing to a specific format works the same as for a single image
            image.Format = MagickFormat.Ptif
            image.Write("C:\Temp\MyTEST.pdf.Page" & page & ".tif")
            page += 1
        Next
    End Using
End Sub

it doesn't seem to like " Images.read " or anything to do with Image,
Any Ideas ? Please help.
Dec 8, 2015 at 12:57 PM
Does this only happen with PDF files? Which version of Ghostscript did you install?
Dec 8, 2015 at 3:43 PM
Hi,
Yes it was only happening with PDF files, and thanks for the TIP because Ghostscript was missing. I thought I had in on my pc but since my PC was recently re-built it never went back on. I have now installed version gs 9.18 and the code ran without any errors. I am able to convert PDFs into Tiffs but there is quality issue which I need to look into further. so far I am exploring the capabilities for conversion from each type. I Noticed from a Two Pages PDF file sized with 44KB has created two TIF files of 45,647KB each with low quality, which is not quite right. I will test it further and if I keep getting this sort or poor quality I will ask for help unless if you already aware of this issue of converting from PDFs -> TIFF and loosing quality.

thanks again.
Dec 8, 2015 at 4:01 PM
The cause of low quality TIF files could be due to a low Density but 300 looks enough. Isn't it possible that whatever you using to view it is resizing the image and making it look like a bad quality file. Another cause could be that your PDF contains images and the are 'scaled up' making it a bad quality image.

Do you still get the stackoverflow exception when you uninstall Ghostscript from your machine? I would really like to fix the issue. I have had other reports about it but I was never able to reproduce the problem.
Dec 8, 2015 at 4:23 PM
Thanks again for your prompt reply, I can certainly try to test if "stackoverflow exception" error re-occurs by un-installing GPL-GhostScript.
will update you soon with my results.
Dec 8, 2015 at 4:32 PM
"stackoverflow exception" error only occurs when GhostScript is missing from my PC.
Dec 8, 2015 at 8:01 PM
Edited Dec 8, 2015 at 8:29 PM
I get a MagickDelegateErrorException that complains a file (Ghostscript) could not be found. Does it also occur when you run convert.exe on the command line? Could you provide me with a memory dump if it also happens there?
Dec 9, 2015 at 7:55 AM
should I test this with GhostScript un-installed or Installed ? previous tests were done using the com object : "Magick.NET.Wrapper-x86.dll" in Visual STudio 2005.
Dec 9, 2015 at 8:01 AM
Without Ghostscript installed please.