PCL to PNG Conversion error

Jun 27, 2014 at 4:29 PM
Edited Jun 27, 2014 at 4:30 PM
Hi there,
I am trying to convert a PCL file into a PNG (or any image format really).
However I keep getting an "AccessViolationException" when I attempt to open my pcl file through Magick.NET.
This is a WPF application being built in Visual Studio 2013.
I am using the x86 version of Magick.Net
I have ghostscript installed, I have the C++ redistributable installed.

I have tested converting other image file types, so I know the tool works, but when I attempt a PCL file it fails with that exception.

Any help you can provide would be fantastic.

Thank you!


Here is my code:
var settings = new MagickReadSettings {Format = MagickFormat.Pcl};
var pclToBmp = new MagickImage(@"C:\Projects\PCLTest.pcl", settings);
pclToBmp.Write(@"C:\Projects\temp.png");
and here is the exception detail and stack trace
"Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

at Magick.Image.read(Image* , basic_string<char\,std::char_traits<char>\,std::allocator<char> > )
at ImageMagick.MagickReader.Read(Image
image, String fileName, MagickReadSettings readSettings)
at ImageMagick.MagickImage..ctor(String fileName, MagickReadSettings readSettings)
<..the remainder of the stack is my code..>

And here is the debug output from Magick.Net

2014-06-27T11:19:29-05:00 0:00.031 0.047u 6.8.8 Policy Magick[5408]: policy.c/IsRightsAuthorized/574/Policy
Domain: Path; rights=Read; pattern="C:\Projects\PCLTest.pcl" ...

2014-06-27T11:19:29-05:00 0:00.054 0.063u 6.8.8 Blob Magick[5408]: blob.c/OpenBlob/2538/Blob
read 3 magic header bytes

2014-06-27T11:19:29-05:00 0:00.056 0.063u 6.8.8 Cache Magick[5408]: cache.c/DestroyPixelCache/961/Cache
destroy

2014-06-27T11:19:29-05:00 0:00.057 0.063u 6.8.8 Configure Magick[5408]: configure.c/GetConfigureOptions/678/Configure
Searching for configure file: "magic.xml"

2014-06-27T11:19:29-05:00 0:00.058 0.063u 6.8.8 Configure Magick[5408]: configure.c/GetConfigureOptions/678/Configure
Searching for configure file: "C:\Users\jeffn.config\ImageMagick\magic.xml"

2014-06-27T11:19:29-05:00 0:00.060 0.063u 6.8.8 Configure Magick[5408]: configure.c/GetConfigureOptions/678/Configure
Searching for configure file: "C:\Users\jeffn.magick\magic.xml"

2014-06-27T11:19:29-05:00 0:00.061 0.063u 6.8.8 Configure Magick[5408]: magic.c/LoadMagicCache/774/Configure
Loading magic configure file "magic.xml" ...

2014-06-27T11:19:29-05:00 0:00.062 0.063u 6.8.8 Policy Magick[5408]: policy.c/IsRightsAuthorized/574/Policy
Domain: Coder; rights=Read; pattern="PCL" ...

2014-06-27T11:19:29-05:00 0:00.064 0.063u 6.8.8 Policy Magick[5408]: policy.c/IsRightsAuthorized/574/Policy
Domain: Path; rights=Read; pattern="C:\Projects\PCLTest.pcl" ...

2014-06-27T11:19:29-05:00 0:00.066 0.063u 6.8.8 Blob Magick[5408]: blob.c/OpenBlob/2538/Blob
read 3 magic header bytes

2014-06-27T11:19:29-05:00 0:00.067 0.063u 6.8.8 Cache Magick[5408]: cache.c/DestroyPixelCache/961/Cache
destroy
Coordinator
Jun 27, 2014 at 6:54 PM
Can you post a link to your file or is it confidential?
Jun 27, 2014 at 7:21 PM
The one I was trying is confidential, however I tried it with a few of the files found here:
http://www.pcltools.com/samples.php
I tried "WP51PORT.PCL" and "ACORDFRM.PCL".
I received the same error for both.

Thanks so much for looking at this, I truly appreciate it.
Coordinator
Jun 27, 2014 at 8:30 PM
Thank you for the detailed information and the example. You found a bug in ImageMagick and I just submitted a patch to the svn repository to fix this. I will try to publish a new release this weekend.

ImageMagick uses the executable pcl6.exe (GhostPCL) to read the pcl file. You need to download this and put it in same folder as the Magick.NET dll.
Jun 27, 2014 at 8:45 PM
Thanks for finding a fix!

Just so I'm sure I understand.
Will getting GhostPCL and placing that exe in the same folder as the Magick.NET.dll fix it now with the current published code?
Or do I need to wait to get the new code AND place GhostPCL in the folder?

Thanks!

Also, is this the correct download for GhostPCL?
http://www.ghostscript.com/download/gpcldnld.html
Coordinator
Jun 27, 2014 at 8:59 PM
You have to wait to get the new code AND place GhostPCL in the folder. The new release will be published soon.

That is indeed the correct download.
Jun 27, 2014 at 9:00 PM
That's great!
Thanks so much for help.
I'll check back after the new release is published and let you know how it goes.

-jeff
Jul 7, 2014 at 4:37 PM
Just checked back, pulled down the latest nuget package and this all seems to be working great!
PCL=>PNG conversion functioning fantastically.


I'm running into a different issue now, but I'll submit a new discussion related to that.
Thanks for all your help.