Skip to content

Instantly share code, notes, and snippets.

@johnnyasantoss
Created August 13, 2019 11:00
Show Gist options
  • Save johnnyasantoss/e50b58c549c0a095d36cb8735e6ae934 to your computer and use it in GitHub Desktop.
Save johnnyasantoss/e50b58c549c0a095d36cb8735e6ae934 to your computer and use it in GitHub Desktop.
Reproduction of a bug when trying to write
Unhandled Exception: ImageMagick.MagickDrawErrorException: NonconformingDrawingPrimitiveDefinition `text' @ error/draw.c/RenderMVGContent/4398
at ImageMagick.MagickExceptionHelper.Check(IntPtr exception)
at ImageMagick.DrawingWand.NativeDrawingWand.Render()
at ImageMagick.MagickImage.Draw(IEnumerable`1 drawables)
at ImageMagick.Drawables.Draw(IMagickImage image)
at temp_test.Program.Main(String[] args) in /tmp/temp-test/Program.cs:line 29
using System;
using System.Linq;
using ImageMagick;
namespace temp_test
{
class Program
{
static void Main(string[] args)
{
ImageMagick.MagickNET.SetLogEvents(LogEvents.All);
ImageMagick.MagickNET.Log += (_, e) => Console.WriteLine(e.Message); ;
var img = new MagickImage(args[0]);
// image preparation
img.ColorSpace = ColorSpace.RGB;
img.FilterType = FilterType.Mitchell;
img.Resize(700, 0);
img.ColorSpace = ColorSpace.sRGB;
// equivalent to -matte
img.Alpha(AlphaOption.Set);
img.VirtualPixelMethod = VirtualPixelMethod.Transparent;
new Drawables()
//text settings
.FontPointSize(18)
.Font("Arial Black")
.StrokeColor(MagickColors.Yellow)
.TextAlignment(TextAlignment.Center)
//
.FillColor(MagickColors.Red)
.Text(0, 0, "1b").Text(0, 700, "2b").Text(700, 700, "3b").Text(700, 0, "4b")
.Polyline(new PointD(0, 0), new PointD(0, 700), new PointD(700, 700), new PointD(700, 0))
// exception is thrown here
.Draw(img);
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Magick.NET-Q8-x64" Version="7.14.1" />
</ItemGroup>
</Project>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment