Quantcast
Channel: magick Discussions Rss Feed
Viewing all articles
Browse latest Browse all 3693

New Post: Converting MagicImageCollection to Base64 in parallel

$
0
0
I am using v4.0.30319 of GraphicsMagick.NET.AnyCPU

The code is very simple - I have a byte array containing a multipage tiff. From there the applicable code is
MagickImageCollection returnImage = null;
using (MemoryStream ms = new MemoryStream(ByteData))
{
    try
    {
        returnImage = new MagickImageCollection(ms);
    
        returnImage.AsParallel().ForAll(a => a.Format=MagickFormat.Png);
        returnImage.AsParallel().AsOrdered().ForAll(a =>a.ToBase64());
    }
    catch (Exception e)
    {
        *exception handling*
    }
}
Exception occurs and does not hit my exception handler, it breaks on the Tobase64 line:
An exception of type 'System.ArgumentNullException' occurred in GraphicsMagick.NET-AnyCPU.dll but was not handled in user code

Stack trace:

at GraphicsMagick.MagickImage.ToBase64()
at TestProg.<ConvertBytesToString>b__10(MagickImage a)
at System.Linq.Parallel.ForAllOperator1.ForAllEnumerator1.MoveNext(TInput& currentElement, Int32& currentKey)
at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
at System.Linq.Parallel.SpoolingTaskBase.Work()

Detail:
System.ArgumentNullException was unhandled by user code
HResult=-2147467261
Message=Value cannot be null.
Parameter name: inArray
Source=GraphicsMagick.NET-AnyCPU
ParamName=inArray
StackTrace:
   at GraphicsMagick.MagickImage.ToBase64()
   at TestProg.<ConvertBytesToString>b__10(MagickImage a) 
   at System.Linq.Parallel.ForAllOperator`1.ForAllEnumerator`1.MoveNext(TInput& currentElement, Int32& currentKey)
   at System.Linq.Parallel.ForAllSpoolingTask`2.SpoolingWork()
   at System.Linq.Parallel.SpoolingTaskBase.Work()
InnerException:

Viewing all articles
Browse latest Browse all 3693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>