title: To resize automatically a picture to A4 in LaTeX
body: <p>I have many pictures which size differ much from picture to picture.</p>
  
  <p>I aim to develop an algorithm which allows you to remove the extra whitespace. Such algorithms are used in Signal Processing in removing the redundant noise, for instance in mobile phones.</p>
  
  <p>The algorithm should be used as follows</p>
  
  <pre><code> \includegraphics[crop-redundant-whitespace]{picture.png} 
  </code></pre>
  
  <p>The function <code>crop-redundant-whitespace</code> should change the include -command, for instance to </p>
  
  <pre><code> \includegraphics[width=2.5cm, height=5.0cm]{picture.png}
  </code></pre>
  
  <p>The algorithm should </p>
  
  <ul>
  <li>detect parts of size at least 2cm in length which are separate from each other</li>
  <li>if many large parts exist, then the biggest part should be selected.</li>
  </ul>
  
  <p><strong>How can you automatically resize pictures and make them fix to A4?</strong></p>