title: How to add transparent padding to a jpg and save it as png with transparency?
body: <p>The documentation for SixLabors ImageSharp is very limited, and most google searches leads to GitHub, which is not very helpful.</p>
  
  <p>How can I upload a jpg, <code>.Mutate</code> it with transparent padding and save it as a png with transparency?</p>
  
  <p>This is the code I have so far. If the uploaded image is a png, transparent padding works, but jpgs get black padding:</p>
  
  <pre><code>private static void ResizeAndSavePhoto(Image&lt;Rgba32&gt; img, string path, int squareSize)
  {
      Configuration.Default.ImageFormatsManager.SetEncoder(PngFormat.Instance, new PngEncoder()
      {
          ColorType = PngColorType.RgbWithAlpha
      });
      img.Mutate(x =&gt;
          x.Resize(new ResizeOptions
          {
              Size = new Size(squareSize, squareSize),
              Mode = ResizeMode.Pad
          }).BackgroundColor(new Rgba32(255, 255, 255, 0))
          );
      img.Save(path);
      return;
  }
  </code></pre>
  
  <p><code>.SaveAsPng()</code> takes a filestream, but I have an <code>Image&lt;Rgba32&gt;</code> and a path...</p>