title: How to batch resize millions of images to fit a max width and height?
body: <h3>The situation</h3>
  
  <p>I'm looking for a way to batch-resize approximately 15 million images of different file types to fit a certain bounding box resolution (in this case the image(s) cannot be bigger than 1024*1024), without distorting the image and thus retaining the correct aspect ratio. All files are currently located on a Linux server on which I have sudo access, so if I need to install anything, I'm good to go.</p>
  
  <h3>Things I've tried</h3>
  
  <p>After dabbling around with some tools under Windows (Adobe Photoshop and other tools) I am no longer willing to run this on my own machine as this renders it virtually unusable when rendering. Considering the size of this job, I'm really looking for some command-line magic to directly run it on Linux, but my endeavors with ImageMagick so far haven't given me anything to work with as I'm getting nothing but errors.
  To be honest, ImageMagick's documentation could use some work... or someone should put in the effort to make a good web-interface to create one of these mythical image convertion one-liners.</p>
  
  <h3>Required output format</h3>
  
  <p>I need the images to be resized to the same filename and of a format which will fit inside a certain maximum dimension, for example 1024*1024, meaning:</p>
  
  <ul>
  <li>a JPG of 2048*1024 becomes a JPG of 1024*512 at 75% quality</li>
  <li>a PNG of 1024*2048 becomes a PNG of 512*1024</li>
  </ul>
  
  <p>The resulting image should contain no additional transparent pixels to fill up the remaining pixels; I'm just looking for a way to convert the images to a limited resolution.</p>
  
  <p>Thanks for any help!</p>