More robust support for converting bitmap to vector
diff --git a/ChangeLog b/ChangeLog
index c36252b..cfc99c6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,7 @@
 2019-08-19  7.0.8-62 Cristy  <quetzlzacatenango@image...>
   * Conditionally compile call to AcquireCLocale() (reference
     https://github.com/ImageMagick/ImageMagick/issues/1669).
+  * More robust support for converting bitmap to vector.
 
 2019-08-16  7.0.8-61 Cristy  <quetzlzacatenango@image...>
   * Release ImageMagick version 7.0.8-61, GIT revision 16033:0c5808c:20190816.
diff --git a/coders/svg.c b/coders/svg.c
index 606d9da..39f5a1d 100644
--- a/coders/svg.c
+++ b/coders/svg.c
@@ -3979,6 +3979,7 @@
   {
     char
       *base64,
+      filename[MagickPathExtent],
       message[MagickPathExtent];
 
     Image
@@ -3987,6 +3988,9 @@
     ImageInfo
       *image_info;
 
+    MagickBooleanType
+      status;
+
     register char
       *p;
 
@@ -4000,6 +4004,15 @@
     unsigned char
       *blob;
 
+    image_info=AcquireImageInfo();
+    (void) CopyMagickString(image_info->magick,"TRACE",MagickPathExtent);
+    (void) FormatLocaleString(filename,MagickPathExtent,"trace:%s",
+      image_info->filename);
+    (void) CopyMagickString(image_info->filename,filename,MagickPathExtent);
+    status=WriteImage(image_info,image,exception);
+    image_info=DestroyImageInfo(image_info);
+    if (status != MagickFalse)
+      return(status);
     (void) WriteBlobString(image,
       "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n");
     (void) WriteBlobString(image,
diff --git a/config/delegates.xml.in b/config/delegates.xml.in
index e0da923..688adf7 100644
--- a/config/delegates.xml.in
+++ b/config/delegates.xml.in
@@ -92,6 +92,7 @@
   <delegate decode="pcl:mono" stealth="True" command="&quot;@PCLDelegate@&quot; -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=@PCLMonoDevice@&quot; -dTextAlphaBits=%u -dGraphicsAlphaBits=%u &quot;-r%s&quot; %s &quot;-sOutputFile=%s&quot; &quot;%s&quot;"/>
   <delegate decode="pdf" encode="eps" mode="bi" command="&quot;@PSDelegate@&quot; -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 -sPDFPassword=&quot;%a&quot; &quot;-sDEVICE=@GSEPSDevice@&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;"/>
   <delegate decode="pdf" encode="ps" mode="bi" command="&quot;@PSDelegate@&quot; -sstdout=%%stderr -dQUIET -dSAFER -dBATCH -dNOPAUSE -dNOPROMPT -dMaxBitmap=500000000 -dAlignToPixels=0 -dGridFitTT=2 &quot;-sDEVICE=@GSPSDevice@&quot; -sPDFPassword=&quot;%a&quot; &quot;-sOutputFile=%o&quot; &quot;-f%i&quot;"/>
+  <delegate decode="pnm" encode="trace" command="&quot;@TraceEncodeDelegate@&quot; --svg --output &quot;%o&quot; &quot;%i&quot;"/>
   <delegate decode="png" encode="webp" command="&quot;@WebPEncodeDelegate@&quot; -quiet %Q &quot;%i&quot; -o &quot;%o&quot;"/>
   <delegate decode="pnm" encode="ilbm" mode="encode" command="&quot;@ILBMEncodeDelegate@&quot; -24if &quot;%i&quot; &gt; &quot;%o&quot;"/>
   <delegate decode="bmp" encode="jxr" command="@MVDelegate@ &quot;%i&quot; &quot;%i.bmp&quot;; &quot;@JXREncodeDelegate@&quot; -i &quot;%i.bmp&quot; -o &quot;%o.jxr&quot;; @MVDelegate@ &quot;%i.bmp&quot; &quot;%i&quot;; @MVDelegate@ &quot;%o.jxr&quot; &quot;%o&quot;"/>
diff --git a/configure.ac b/configure.ac
index b4c2106..7a5065a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3197,6 +3197,7 @@
 RMDelegateDefault='rm'
 RSVGDecodeDelegateDefault='rsvg-convert'
 SVGDecodeDelegateDefault='inkscape'
+TraceEncodeDelegateDefault='potrace'
 UniconvertorDelegateDefault='uniconvertor'
 WebPDecodeDelegateDefault='dwebp'
 WebPEncodeDelegateDefault='cwebp'
@@ -3243,6 +3244,7 @@
 AC_PATH_PROG(RMDelegate, "$RMDelegateDefault", "$RMDelegateDefault")
 AC_PATH_PROG(RSVGDecodeDelegate, "$RSVGDecodeDelegateDefault", "$RSVGDecodeDelegateDefault")
 AC_PATH_PROG(SVGDecodeDelegate, "$SVGDecodeDelegateDefault", "$SVGDecodeDelegateDefault")
+AC_PATH_PROG(TraceEncodeDelegate, "$TraceEncodeDelegateDefault", "$TraceEncodeDelegateDefault")
 AC_PATH_PROG(UniconvertorDelegate, "$UniconvertorDelegateDefault", "$UniconvertorDelegateDefault")
 AC_PATH_PROG(WebPDecodeDelegate, "$WebPDecodeDelegateDefault", "$WebPDecodeDelegateDefault")
 AC_PATH_PROG(WebPEncodeDelegate, "$WebPEncodeDelegateDefault", "$WebPEncodeDelegateDefault")
@@ -3442,6 +3444,7 @@
   RSVGDecodeDelegate="$RSVGDecodeDelegateDefault"
   SVGDecodeDelegate="$SVGDecodeDelegateDefault"
   ShowImageDelegate="$ShowImageDelegateDefault"
+  TraceEncodeDelegate="$TraceEncodeDelegateDefault"
   UniconvertorDelegate="$UniconvertorDelegateDefault"
   WebPDecodeDelegate="$WebPDecodeDelegateDefault"
   WebPEncodeDelegate="$WebPEncodeDelegateDefault"
@@ -3474,6 +3477,7 @@
 AC_SUBST(PCLDelegate)
 AC_SUBST(PSDelegate)
 AC_SUBST(ShowImageDelegate)
+AC_SUBST(TraceEncodeDelegate)
 AC_SUBST(UniconvertorDelegate)
 AC_SUBST(WebPDecodeDelegate)
 AC_SUBST(WebPEncodeDelegate)