Support -define connected-components:remove define
diff --git a/MagickCore/distort.c b/MagickCore/distort.c
index e5c5bd7..af78f6c 100644
--- a/MagickCore/distort.c
+++ b/MagickCore/distort.c
@@ -1572,6 +1572,13 @@
tmp_image=resize_image;
resize_image=CropImage(tmp_image,&crop_area,exception);
tmp_image=DestroyImage(tmp_image);
+ if (resize_image != (Image *) NULL)
+ {
+ resize_image->alpha_trait=image->alpha_trait;
+ resize_image->compose=image->compose;
+ resize_image->page.width=0;
+ resize_image->page.height=0;
+ }
return(resize_image);
}
diff --git a/MagickCore/vision.c b/MagickCore/vision.c
index 64a5db9..aca2dc7 100644
--- a/MagickCore/vision.c
+++ b/MagickCore/vision.c
@@ -551,6 +551,41 @@
component_image->colormap[i].alpha=object[i].color.alpha;
}
}
+ artifact=GetImageArtifact(image,"connected-components:remove");
+ if (artifact != (const char *) NULL)
+ {
+ char
+ *p;
+
+ long
+ first,
+ last,
+ step;
+
+ /*
+ Remove these objects (make them transparent).
+ */
+ for (p=(char *) artifact; *p != '\0';)
+ {
+ while ((isspace((int) ((unsigned char) *p)) != 0) || (*p == ','))
+ p++;
+ first=strtol(p,&p,10);
+ if (first < 0)
+ first+=(long) component_image->colors;
+ last=first;
+ while (isspace((int) ((unsigned char) *p)) != 0)
+ p++;
+ if (*p == '-')
+ {
+ last=strtol(p+1,&p,10);
+ if (last < 0)
+ last+=(long) component_image->colors;
+ }
+ component_image->alpha_trait=BlendPixelTrait;
+ for (step=first > last ? -1 : 1; first != (last+step); first+=step)
+ component_image->colormap[first].alpha=TransparentAlpha;
+ }
+ }
(void) SyncImage(component_image,exception);
artifact=GetImageArtifact(image,"connected-components:verbose");
if (IsStringTrue(artifact) != MagickFalse)