title: imagemagick read image from memory C#
body: <p>So we have public class which pass image there named string fileName, I need to use MaigickImage with MemoryStream or byte[] because this is a web, there is no point in the address to the file. Somehow I need to pass string fileName into MemoryStream and then pass it to MagickImage. When I am using new MagickImage(&quot;fileName&quot;) it gave me error such no file or dirrectiry found. So I need it to pass thru MemoryStream or byte[] without using MagickImage(&quot;fileName&quot;)</p>
  <pre><code>        private void Update(ClientFileType type, FileData newFile, int clientId, string fileName)
          {
  
  
  using (var image = new MagickImage(&quot;fileName&quot;))
  {
      // Save frame as jpg
      image.Write(&quot;fileName&quot;);
  }
  
  // Write to stream
  var settings = new MagickReadSettings();
  // Tells the xc: reader the image to create should be 800x600
  settings.Width = 800;
  settings.Height = 600;
  
  using (var memStream = new MemoryStream())
  {
      // Create image that is completely purple and 800x600
      using (var image = new MagickImage(&quot;xc:purple&quot;, settings))
      {
          // Sets the output format to png
          image.Format = MagickFormat.Png;
  
          // Write the image to the memorystream
          image.Write(memStream);
      }
  }
  
  // Read image from file
  using (var image = new MagickImage(&quot;fileName&quot;))
  {
      // Sets the output format to jpeg
      image.Format = MagickFormat.Jpeg;
  
      // Create byte array that contains a jpeg file
      byte[] data = image.ToByteArray();
  }
  
              var currentFiles = 
                  _clientFileService.Value.GetFilesByClient(clientId).Where(x =&gt; x.ClientFileType == type).Select(x =&gt; x.Id).ToList();
  
              _clientFileService.Value.MultipleDelete(currentFiles, null);
  
              _clientFileService
                  .Value
                  .AddFile(
                  new ClientFile
                  {
                      FileName = fileName,
                      Guid = Guid.NewGuid()
                  });
          }
  </code></pre>