Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BypolarInterpolate ¶
BypolarInterpolate resizes an image using Bypolar interpolation. This method calculates pixel values in the resized image by interpolating between the four nearest pixels in the original image. It provides smoother results compared to nearest neighbor interpolation, making it suitable for both enlarging and reducing images while maintaining better visual quality.
Parameters:
- img: The input image to be resized
- newWidth: The desired width of the resized image (in pixels)
- newHeight: The desired height of the resized image (in pixels)
Returns:
- image.Image
func NearestNeighbor ¶
NearestNeighbor resizes an image using nearest neighbor interpolation. This is the simplest and fastest resizing algorithm that works by selecting the color of the nearest pixel in the original image for each pixel in the resized image. While efficient, it may produce pixelated results, especially when significantly enlarging images.
Parameters:
- img: The input image to be resized
- newWidth: The desired width of the resized image (in pixels)
- newHeight: The desired height of the resized image (in pixels)
Returns:
- image.Image
func NewAspectRatio ¶
NewAspectRatio calculates the new dimensions for an image while preserving the aspect ratio. Given a new target width, this function computes the proportionally correct height to maintain the original image's proportions, preventing distortion.
Parameters:
- img: The input image whose aspect ratio should be preserved
- newWidth: The desired width of the resized image (in pixels)
Returns:
- int: The requested new width (same as input newWidth)
- int: The calculated new height that preserves aspect ratio
Types ¶
This section is empty.