title: Resizing with a max width/height while keeping the original ratio using Intervention Image in Laravel
body: <p>I want to constrain an image only if they exceed <strong>either</strong> maximum dimensions while keeping the original ratio intact.  </p>
  
  <p>So let's say my parameters are a max height and width of 600.</p>
  
  <p>An image of 1000x1000 would become 600x600, simple enough.</p>
  
  <p>An image of 2000x1000 would become 600x300. This would mean that the highest of the two values becomes 600, while the other gets constrained proportionally.</p>
  
  <p>Something like this</p>
  
  <pre><code>            $image-&gt;resize(600, 600, function ($constraint) {
                  $constraint-&gt;aspectRatio();
              });
  </code></pre>
  
  <p>What would be the best way to go about this?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>As per the comments, I tried this: </p>
  
  <pre><code>    $medium = Image::make($file);
  
      $medium-&gt;resize(null, 500, function ($constraint) {
          $constraint-&gt;aspectRatio();
      });
  
      $medium-&gt;resize(500, null, function ($constraint) {
          $constraint-&gt;aspectRatio();
      });             
      $medium-&gt;save( public_path('/uploads/artistUploads/medium-' . $filename , 90) );    
  </code></pre>
  
  <p>This does not work. Only the first resize is applied, which in this case is width.</p>
  
  <p>HOWEVER, turns out the original code does work. I simply assumed it wouldn't, but it does.</p>