code: func cropAndResize(img image.Image, width, height int, anchor Anchor, filter ResampleFilter) *image.NRGBA {
  	dstW, dstH := width, height
  
  	srcBounds := img.Bounds()
  	srcW := srcBounds.Dx()
  	srcH := srcBounds.Dy()
  	srcAspectRatio := float64(srcW) / float64(srcH)
  	dstAspectRatio := float64(dstW) / float64(dstH)
  
  	var tmp *image.NRGBA
  	if srcAspectRatio < dstAspectRatio {
  		cropH := float64(srcW) * float64(dstH) / float64(dstW)
  		tmp = CropAnchor(img, srcW, int(math.Max(1, cropH)+0.5), anchor)
  	} else {
  		cropW := float64(srcH) * float64(dstW) / float64(dstH)
  		tmp = CropAnchor(img, int(math.Max(1, cropW)+0.5), srcH, anchor)
  	}
  
  	return Resize(tmp, dstW, dstH, filter)
  }
docs: // cropAndResize crops the image to the smallest possible size that has the required aspect ratio using
  // the given anchor point, then scales it to the specified dimensions and returns the transformed image.
  //
  // This is generally faster than resizing first, but may result in inaccuracies when used on small source images.