title: Ghostscript: Set pixel width while maintaing aspect ratio, EPS to PNG
body: <p>I read through the usage documentation, and could not find any way to output an image X pixels wide, with the height determined by the aspect ratio. I have a large amount of EPS files I need to rasterize, and they need to be at least 2400px wide. My current workaround is to set a usually-high-enough resolution using the <code>-r</code> flag, but this makes many of the images much, much larger than I need them to be.</p>
  
  <p>I am currently using this command:</p>
  
  <pre><code>gs -dNOPAUSE -sDEVICE=pngalpha -dEPSCrop -sOutputFile=./result.png -r500x500 -dEPSFITPAGE -dBATCH -dQUIET ./input.eps
  </code></pre>
  
  <p>I have experimented with different combinations and settings of <code>-g</code>, <code>-dDEVICEWIDTH</code>, <code>-dDEVICEHEIGHT</code>, <code>-dFIXEDMEDIA</code>, <code>-dFIXEDRESOLUTION</code>, and <code>-dFitPage</code>, however I could not figure it out.</p>
  
  <p>I have a feeling there may be some kind math needed to simply set the correct value for <code>-r</code> that will yield the desired dimensions, but I'm not sure how to go about this. Any help appreciated!</p>