ImageMagick create circle count on top of image
Posted: 2018-03-27T20:36:00-07:00
Hey all I have the following Magick.net code:
And this comes out looking like this:
But what I am looking to want it to look like is this:
I'm having issues with just making a red circle with a black outline and shadow with the text XX+ inside it. Also, I've looked high and low to find out how i can position it where I need it but I am unable to find it. I thought that MagickGeometry would be it but it turns out that its not.
Code: Select all
List<string> lFiles = new List<string>();
bool isBlankImage = false;
lFiles.Add(@"C:\Users\David\Pictures\1.jpg");
lFiles.Add(@"C:\Users\David\Pictures\blank.png");
lFiles.Add(@"C:\Users\David\Pictures\blank.png");
lFiles.Add(@"C:\Users\David\Pictures\blank.png");
lFiles.Add(@"C:\Users\David\Pictures\blank.png");
IMagickImage roundImg = new MagickImage();
IMagickImage mask = new MagickImage();
IMagickImage shadow = new MagickImage();
IMagickImage result = new MagickImage();
foreach (string tempFBProfileImg in lFiles)
{
roundImg = new MagickImage(tempFBProfileImg);
if (Regex.IsMatch(tempFBProfileImg.ToLower(), @"\bblank.png\b"))
{
result.Extent(360, 100, Gravity.West);
images.Add(result);
isBlankImage = true;
break;
}
else
{
mask = new MagickImage("xc:black", 100, 100);
mask.Settings.FillColor = MagickColors.White;
mask.Draw(new DrawableCircle(50, 50, 50, 90));
mask.HasAlpha = false;
roundImg.Resize(100, 100);
roundImg.Composite(mask, CompositeOperator.CopyAlpha);
roundImg.Draw(new DrawableStrokeColor(MagickColors.Black),
new DrawableStrokeWidth(1),
new DrawableFillColor(MagickColors.None),
new DrawableCircle(50, 50, 50, 90));
shadow = new MagickImage("xc:none", 100, 100);
shadow.Settings.FillColor = MagickColors.Black;
shadow.Draw(new DrawableCircle(50, 50, 50, 90));
shadow.Blur(0, 5);
roundImg.Composite(shadow, CompositeOperator.DstOver);
images.Add(roundImg);
images.First().BackgroundColor = MagickColors.None;
result = images.SmushHorizontal(-35);
result.Resize(100, 100);
result.Write(@"C:\Users\David\Pictures\final2.png");
}
}
var imgText = new MagickImage(MagickColors.Blue, 0, 0);
imgText.Settings.FontPointsize = 24;
imgText.BackgroundColor = MagickColors.White;
imgText.Settings.FillColor = MagickColors.Black;
imgText.Settings.TextAntiAlias = true;
imgText.Settings.FontFamily = "Arial";
imgText.Read("label: 10+", 45, 25);
string caption = "label:10+";
//imgText = new MagickImage(caption, settings);
//imgText.Draw(new DrawableText(100, 20, "10+"));
imgText.Page = new MagickGeometry(300, 100, 0, 0);
result.Composite(imgText, CompositeOperator.Over);
result.Write(@"C:\Users\David\Pictures\final2.png");
But what I am looking to want it to look like is this:
I'm having issues with just making a red circle with a black outline and shadow with the text XX+ inside it. Also, I've looked high and low to find out how i can position it where I need it but I am unable to find it. I thought that MagickGeometry would be it but it turns out that its not.