Documentation
¶
Index ¶
- Constants
- func EncodeImage(img image.Image, format types.ImageFormat, quality int) ([]byte, error)
- func InitializeNvidiaLib(libName, libTag string, fileCheck *types.FileCheck, ...) error
- func IsCoreMLSupported() bool
- func IsCudaSupported() bool
- func IsTensorRtSupported() bool
- func LoadImage(path string) (*types.ImageData, error)
- func SaveImage(data *types.ImageData, format types.ImageFormat, quality int) (int, error)
- func SupportedImageExtensions() []string
Constants ¶
const ( CudaTag = "cuda/12.9.1" CudnnTag = "cudnn/9.14.0" TensorrtTag = "tensorrt/10.9.0" )
Variables ¶
This section is empty.
Functions ¶
func EncodeImage ¶
EncodeImage encodes an image into a byte array in the specified format with the given quality level.
Parameters: ¶
- img: The image.Image to be encoded.
- format: The target image format (e.g., FormatBmp, FormatJpeg, FormatPng).
- quality: The quality level for lossy formats like JPEG (0-100, where 100 is the highest quality).
Returns: ¶
- []byte: The encoded image data as a byte slice.
- error: An error if the format is unsupported or encoding fails.
func InitializeNvidiaLib ¶
func InitializeNvidiaLib(libName, libTag string, fileCheck *types.FileCheck, onProgress types.DownloadProgress) error
InitializeNvidiaLib downloads and initializes an NVIDIA library dependency.
It constructs a download URL based on the library name, tag, and current OS/architecture, then downloads and extracts the library to the user's config directory. The library path is added to the environment PATH for runtime discovery.
Parameters: ¶
- libName: The name of the NVIDIA library (e.g., "cuda", "cudnn", "tensorrt").
- libTag: The version tag used in the download URL (e.g., "cuda/12.9.1").
- checkFile: A file path used to verify if the library is already installed.
- onProgress: A callback function to report download progress.
Returns an error if the download, extraction, or path configuration fails.
func IsCoreMLSupported ¶
func IsCoreMLSupported() bool
IsCoreMLSupported always returns false on non-macOS platforms.
func IsCudaSupported ¶
func IsCudaSupported() bool
IsCudaSupported performs a simplified check whether the system has an NVIDIA GPU that possibly supports CUDA.
Returns false if an error occurs while querying GPU information or no NVIDIA GPU is found.
func IsTensorRtSupported ¶
func IsTensorRtSupported() bool
IsTensorRtSupported performs a simplified check whether the system has an NVIDIA GPU that possibly supports TensorRT.
Returns false if an error occurs while querying GPU information or no NVIDIA GPU is found.
func LoadImage ¶
LoadImage loads an image file from the specified path and returns it as ImageData.
The function opens the file, decodes the image data, and constructs an ImageData structure containing both the file path and the decoded pixel data.
Parameters: ¶
- path: The file system path to the image file to be loaded
Returns: ¶
- *types.ImageData: A pointer to the ImageData structure containing the file path and decoded image
- error: An error if the file cannot be opened or the image cannot be decoded
func SaveImage ¶
SaveImage saves the image data to a file in the specified format. The output format is determined by the Format field in the OutputImage structure.
Parameters: ¶
- data: A pointer to OutputImage containing the file path, pixel data, and desired format.
- format: The image format to save the image data as.
- quality: The quality level the encoding (0-100, where 100 is the highest quality).
Returns: ¶
- int64: The size of the saved file in bytes.
- error: An error if the quality is out of range, the file cannot be created, or encoding fails.
func SupportedImageExtensions ¶
func SupportedImageExtensions() []string
SupportedImageExtensions returns a list of image file extensions that the application can process.
The returned extensions include common image formats that have registered decoders and encoders in this package. File extensions are returned in lowercase without the leading dot.
Returns: ¶
- []string: A slice of supported image file extensions
Types ¶
This section is empty.