title: Ruby: how to crop and resize image from center
body: <p>I am trying to resize an image and crop it from the center. i.e. if the resolution is 1024x512 and I want to resize by 256x256 I would resize the smallest side to 256 and maintain aspect ratio, i.e. resize the image to 512x256 and then I want to crop the 256x256 square from the centre.</p>
  
  <p>I have seen solutions with paperclip but only for Rails, but I'm not sure how to do this in just a regular script.</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks</p>