title: Restrict the Image byte array conversion to PNG format
body: <p>I've a Web API which takes images (it can be jpeg or png) from a folder and convert it to byte array and send to the calling application.</p>
  
  <p>I use the below function to convert the images to binary:</p>
  
  <pre><code>public static byte[] ImageToBinary(string imagePath)
  {
      FileStream fS = new FileStream(imagePath, FileMode.Open, FileAccess.Read);
      byte[] b = new byte[fS.Length];
      fS.Read(b, 0, (int)fS.Length);
      fS.Close();
      return b;
  }
  </code></pre>
  
  <p>And below 'data' will be passed to the Web API response.</p>
  
  <pre><code>byte[] data = ImageToBinary(&lt;PATH HERE&gt;);
  </code></pre>
  
  <p>What I want is to restrict this 'data' to be converted to PNG format only in the application from where this Web API is called. </p>
  
  <p>Purpose is that I don't want every time to remind the other developer who is coding the other application that you need to convert it to PNG only.</p>