code: func rescale(im image.Image, sw, sh int) image.Image {
  	b := im.Bounds()
  	w, h := b.Dx(), b.Dy()
  	if sw == w && sh == h {
  		return im
  	}
  
  	// If it's gigantic, it's more efficient to downsample first
  	// and then resize; resizing will smooth out the roughness.
  	// (trusting the moustachio guys on that one).
  	if w > sw*2 && h > sh*2 {
  		im = resize.ResampleInplace(im, b, sw*2, sh*2)
  		return resize.HalveInplace(im)
  	}
  	return resize.Resize(im, b, sw, sh)
  }
docs: // rescale resizes im in-place to the dimensions sw x sh, overwriting the
  // existing pixel data.  It is up to the caller to ensure sw & sh maintain the
  // aspect ratio of im.