title: How to resize all images in a block of HTML to a specific width and cache the results
body: <p>I'm writing a mobile content adaptation plugin for a bespoke CMS in PHP. The CMS contains <code>&lt;img/&gt;</code> links to images with absolute URLs which are all 400 pixels wide and vary in height.</p>
  
  <p>I'd like to parse the HTML (which is stored in MySQL) and re-scale each image to a new width - this will vary according to the device. I'd also like to cache the images to prevent needlessly resizing them on-the-fly every time the page is loaded</p>
  
  <p>What's the best way for me to achieve this in PHP using either ImageMagick or GD? </p>