title: ImageProcessor - Resize to a specified width (automatic height)
body: <p>I'm using the <a href="http://imageprocessor.org/" rel="nofollow noreferrer">ImageProcessor</a> library in my App.</p>
  
  <p>I'm using this code in order to resize to a given specific dimensions ( width+height) : </p>
  
  <pre><code> public static byte[] ResizeImage(byte[] inputFileBytes, int w, int h, ResizeMode resizeMode)
          {
              byte[] photoBytes = inputFileBytes; 
  
              ISupportedImageFormat format = new JpegFormat { Quality = 70, IsIndexed = false };
              Size size = new Size(w, h);
              using (MemoryStream inStream = new MemoryStream(photoBytes))
              using (MemoryStream outStream = new MemoryStream())
              {
  
                  using (ImageFactory imageFactory = new ImageFactory(preserveExifData: false))
                  {
                      var r = new ResizeLayer(size, resizeMode);
  
                      imageFactory.Load(inStream)
                          .Resize(r)
                          .Format(format)
                          .Save(outStream);
                  }
  
  
                  return outStream.ToArray();
              }
          }
  </code></pre>
  
  <p>I invoke it via (This is a crop <em>example</em> ): </p>
  
  <pre><code>   byte[] servedImage =  ResizeImage(byteArray,[...imgWidth...],
                         [...imgHeight...],ResizeMode.Crop);
  </code></pre>
  
  <p>This all works good.</p>
  
  <p>But now I need to resize the image to a <em>specific</em> <code>width</code> — And I want the height to be proportional.</p>
  
  <p>I already know that the <a href="http://imageprocessor.org/imageprocessor/imagefactory/resize/" rel="nofollow noreferrer">Resize method</a> has an overload : </p>
  
  <pre><code>public ImageFactory Resize(Size size)
  </code></pre>
  
  <p>But I only have the <code>Width</code> in the <code>size</code> param ( I want the height to be calculated automatically)</p>
  
  <p><strong>Question</strong></p>
  
  <p>How can I resize an Image (<code>byte[]</code>)to a specific <code>Width</code> , maintaining the aspect ration  using  ImageProcessor ?</p>