This project has moved. For the latest updates, please go here.

Creating MagickImage with Width Only and Using Caption to Size Image Height Automatically

Aug 1, 2016 at 4:27 PM
How do you use Magick.NET to produce the same results as this command line? I can't seem to reproduce this using the wrapper:
magick convert -size 980x -font Arial -pointsize 54 -background transparent -fill black caption:"@pokemon.txt" rofl_arial.png
How do you initialize a new MagickImage object specifying only a width in Magick.NET?
Aug 1, 2016 at 7:20 PM
Edited Aug 1, 2016 at 7:20 PM
It is probably the easiest to use the MagickReadSettings class for this. Your command would translate to this:
using (MagickImage image = new MagickImage())
  MagickReadSettings readSettings = new MagickReadSettings()
    Width = 980, // -size 980x
    Font = "Arial", // -font Arial
    FontPointsize = 54, // -pointsize 54
    BackgroundColor = MagickColors.Transparent, // -background transparent
    FillColor = MagickColors.Black // -fill black

  // You will need to read the text yourself. The @ syntax is a security
  // issue and is disabled by default
  string caption = File.ReadAllText("pokemon.txt");

  image.Read("caption:" + caption, readSettings); // caption:"@pokemon.txt"
  image.Write("rofl_arial.png"); // rofl_arial.png