Make a copy of a buffer that is rotated 90 degrees clockwise.
@param {external:canvas|external:image} buffer The original image
@return {external:canvas} The rotated buffer
function rotateClockwise(buffer) {
  var w = buffer.height;
  var h = buffer.width;
  var w2 = Math.floor(w / 2);
  var h2 = Math.floor(h / 2);
  return makeBuffer(w, h, function(context) {
    context.translate(w2, h2);
    context.rotate(Math.PI / 2);
    context.drawImage(buffer, -h2, -w2);
  });
}