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

New Post: Magick.NET-7.0.0.0009-Q16-x64-net40-client Freezing System

$
0
0
This could easily be something I'm doing, I have the identical below, just for .NET 3.5, and this one is built against .NET 4.5 - so when I run the code below, I completely freeze my system. It's so bad, all I can do is turn the computer off and back on. Event Viewer isn't capturing anything and there are some partial files left behind, but no other error message I can see. Any help would appreciated.
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using TDCI.BuyDesign.Configurator.Engine;
using TDCI.BuyDesign.Configurator.Engine.Expressions;
using TDCI.BuyDesign.Configurator.Engine.RuleEngine;

using ImageMagick;

namespace SVGtoRaster
{
    public class SVGtoRaster : IExternalProgram
    {
        public Value Execute(IExecutionState executionState, ReadOnlyRuleParameterCollection parameters,
            ReadOnlyComponentAttributeCollection componentAttributes)
        {
            try
            {
                //do work
                RuleParameter sourceName;
                RuleParameter targetName;
                RuleParameter fileType;
                parameters.TryGetValue("SourceName", out sourceName);
                parameters.TryGetValue("TargetName", out targetName);
                parameters.TryGetValue("FileType", out fileType);
               
                // For DebugView
                Trace.WriteLine("SourceName" + sourceName.Value);
                Trace.WriteLine("TargetName" + targetName.Value);
                Trace.WriteLine("FileType" + fileType);
                
                // Read SVG image from file
                MagickNET.SetTempDirectory(Path.GetDirectoryName(sourceName.Value.ToString()));
                using (MagickImage image = new MagickImage(sourceName.Value.ToString()))
                {
                    image.Format = (MagickFormat)Enum.Parse(typeof(MagickFormat), fileType.Value.ToString(), true);
                    //image.Scale 
                    //image.Format = MagickFormat.Png;
                    image.Write(string.Concat(targetName.Value.ToString(), ".", fileType.Value.ToString()));
                }

                var returnCollection = new SimpleExpressionValueCollection
                {
                    {"returnValue", new Value("Success: EP called")}
                };

                return new Value(returnCollection);
            }
            catch (Exception ex)
            {
                executionState.Trace("SVGtoPNG: Error - " + ex.StackTrace + ", " + ex.Message);
                Trace.WriteLine("SVGtoPNG: Error - " + ex.StackTrace + ", " + ex.Message);

                var errorCollection = new SimpleExpressionValueCollection
                {
                    {"Description", new Value("Error: " + ex.Message)}
                };

                return new Value(errorCollection);
            }

            //throw new NotImplementedException();
        }
    }
}
Thanks

Viewing all articles
Browse latest Browse all 3693

Trending Articles



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