code: func Fit(img image.Image, width, height int, filter ResampleFilter) *image.NRGBA {
  	maxW, maxH := width, height
  
  	if maxW <= 0 || maxH <= 0 {
  		return &image.NRGBA{}
  	}
  
  	srcBounds := img.Bounds()
  	srcW := srcBounds.Dx()
  	srcH := srcBounds.Dy()
  
  	if srcW <= 0 || srcH <= 0 {
  		return &image.NRGBA{}
  	}
  
  	if srcW <= maxW && srcH <= maxH {
  		return Clone(img)
  	}
  
  	srcAspectRatio := float64(srcW) / float64(srcH)
  	maxAspectRatio := float64(maxW) / float64(maxH)
  
  	var newW, newH int
  	if srcAspectRatio > maxAspectRatio {
  		newW = maxW
  		newH = int(float64(newW) / srcAspectRatio)
  	} else {
  		newH = maxH
  		newW = int(float64(newH) * srcAspectRatio)
  	}
  
  	return Resize(img, newW, newH, filter)
  }
docs: // Fit scales down the image using the specified resample filter to fit the specified
  // maximum width and height and returns the transformed image.
  //
  // Example:
  //
  //	dstImage := imaging.Fit(srcImage, 800, 600, imaging.Lanczos)
  //