1

I am new to Magick.net but I am trying to make a file generator. I have had it work fine from within the Linux command line (without the size I prefer though), but I need to make a .net app for use by others that don't have access to Linux, or the web (so using PHP not in question, at least not yet).

Doing something like:

montage -background none -fill black -font Helvetica-Condensed-Light -pointsize 26 label:'Foobar Controller 3.1.4.0 Installer' +set label -shadow -geometry +5+5 test_v3.png

But unsure how to use montage from within the C# .net wrapper.

using (MagickImage image = new MagickImage(new MagickColor("#000000"), 419, 39))
            {
               new Drawables()
              // Draw text on the image

But I am rather confused in how I can accomplish this.

Any advice is greatly appreciated. The documentation seems confusing since I am not doing something "standard", as the output will be previewed in an image panel with the option of saving to the file system.

Jon Weinraub
  • 397
  • 1
  • 8
  • 18

1 Answers1

1

Below is an example of how you would need to translate the command from montage.

using (var images = new MagickImageCollection())
{
  var readSettings = new MagickReadSettings()
  {
    BackgroundColor = MagickColors.None, // -background none
    FillColor = MagickColors.Black, // -fill black
    Font = "Helvetica-Condensed-Light", // -font Helvetica-Condensed-Light
    FontPointsize = 26 // -pointsize 26
  };

  // label:'Foobar Controller 3.1.4.0 Installer'
  var image = new MagickImage("label:Foobar Controller 3.1.4.0 Installer", readSettings);
  image.RemoveAttribute("label"); // +set label
  images.Add(image);

  var montageSettings = new MontageSettings()
  {
    BackgroundColor = MagickColors.None, // -background none
    Shadow = true, // -shadow
    Geometry = new MagickGeometry(5, 5, 0, 0) // -geometry +5+5
  };

  using (MagickImage result = images.Montage(montageSettings))
  {
    result.Write("test_v3.png");
  }
}

But because you are only using the shadow part of Montage you could also execute your code like this:

var readSettings = new MagickReadSettings()
{
   BackgroundColor = MagickColors.None,
   FillColor = MagickColors.Black,
   Font = "Helvetica-Condensed-Light",
   FontPointsize = 26
};

var label = new MagickImage("label:Foobar Controller 3.1.4.0 Installer", readSettings);
using (MagickImage shadow = label.Clone())
{
   // This is what is happening under the hood.
  shadow.Shadow(5, 5, 2.0, new Percentage(80), MagickColors.Black);
  shadow.Composite(label, CompositeOperator.Over);
  shadow.Write("test_v3.png");
}
dlemstra
  • 7,813
  • 2
  • 27
  • 43
  • Hi, i am little bit confused converting **magick montage C:\thumb\*.jpg 160x90 -geometry +0+0 overview.jpg** to .net plz guide – Hi Ten Feb 11 '22 at 06:31