Documentation
¶
Index ¶
- type Image
- func (img *Image) Resize(width, height uint, interp resize.InterpolationFunction) *Image
- func (img *Image) ResizeSelf(width, height uint, interp resize.InterpolationFunction)
- func (img *Image) ResizeToHeight(height uint, interp resize.InterpolationFunction) *Image
- func (img *Image) ResizeToWidth(width uint, interp resize.InterpolationFunction) *Image
- func (img *Image) SaveToFile(path string) error
- func (img *Image) SaveToWriter(writer io.Writer) error
- func (img *Image) Scale(factor float64, interp resize.InterpolationFunction) (*Image, error)
- func (img *Image) ScaleDown(maxWidth, maxHeight uint, interp resize.InterpolationFunction) (*Image, error)
- func (img *Image) ScaleSelf(factor float64, interp resize.InterpolationFunction) error
- func (img *Image) ToBase64() (string, error)
- func (img *Image) ToBytes() ([]byte, error)
- type ImageFormat
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Image ¶
type Image struct {
Image image.Image
Format ImageFormat
Width uint
Height uint
// Metadata
ColorModel color.Model
}
func LoadFromBytes ¶
func LoadFromBytes(format ImageFormat, data []byte) (*Image, error)
LoadFromBytes loads an image from a raw byte slice with the specified format.
func LoadFromFile ¶
LoadFromFile loads an image from the given file path.
func LoadFromReader ¶
func LoadFromReader(format ImageFormat, r io.Reader) (*Image, error)
LoadFromReader loads an image from an io.Reader with the specified format.
func LoadFromURL ¶
LoadFromURL downloads and loads an image from the given URL.
func (*Image) Resize ¶
func (img *Image) Resize(width, height uint, interp resize.InterpolationFunction) *Image
Resize creates a new resized copy of the image using the given dimensions and interpolation. The original image remains unchanged.
func (*Image) ResizeSelf ¶
func (img *Image) ResizeSelf(width, height uint, interp resize.InterpolationFunction)
ResizeSelf resizes the image in place to the given dimensions using the specified interpolation.
func (*Image) ResizeToHeight ¶
func (img *Image) ResizeToHeight(height uint, interp resize.InterpolationFunction) *Image
ResizeToHeight resizes the image to the given height while preserving aspect ratio. The original image remains unchanged.
func (*Image) ResizeToWidth ¶
func (img *Image) ResizeToWidth(width uint, interp resize.InterpolationFunction) *Image
ResizeToWidth resizes the image to the given width while preserving aspect ratio. The original image remains unchanged.
func (*Image) SaveToFile ¶
SaveToFile saves the image to a file on disk in its current format.
func (*Image) SaveToWriter ¶
SaveToWriter writes the image to any io.Writer in its current format.
func (*Image) Scale ¶
Scale creates a new scaled copy of the image by the given factor (e.g., 0.5 for half size). The original image remains unchanged.
func (*Image) ScaleDown ¶
func (img *Image) ScaleDown(maxWidth, maxHeight uint, interp resize.InterpolationFunction) (*Image, error)
ScaleDown creates a new image scaled down to fit within the given max width and height, preserving aspect ratio. The original image remains unchanged.
func (*Image) ScaleSelf ¶
func (img *Image) ScaleSelf(factor float64, interp resize.InterpolationFunction) error
ScaleSelf scales the image in place by the given factor (e.g., 2.0 for double size).
type ImageFormat ¶
type ImageFormat string
const ( FormatJPG ImageFormat = "jpg" FormatJFIF ImageFormat = "jfif" FormatJPE ImageFormat = "jpe" FormatJPEG ImageFormat = "jpeg" FormatPNG ImageFormat = "png" FormatGIF ImageFormat = "gif" FormatTIF ImageFormat = "tif" FormatTIFF ImageFormat = "tiff" FormatTIFF_FX ImageFormat = "tiff-fx" FormatWEBP ImageFormat = "webp" FormatBMP ImageFormat = "bmp" FormatDIB ImageFormat = "dib" FormatXBMP ImageFormat = "x-bmp" )