image

package
v1.5.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package image provides image loading, validation, and encoding utilities.

Index

Constants

View Source
const (
	// MaxImageSize is the maximum allowed image size (5MB)
	MaxImageSize = 5 * 1024 * 1024
)

Variables

View Source
var SupportedTypes = map[string]string{
	".png":  "image/png",
	".jpg":  "image/jpeg",
	".jpeg": "image/jpeg",
	".webp": "image/webp",
	".gif":  "image/gif",
}

SupportedTypes maps file extensions to MIME types

Functions

func FormatBytes

func FormatBytes(bytes int) string

FormatBytes formats byte size as human-readable string

func IsImageFile

func IsImageFile(path string) bool

IsImageFile returns true if the file extension indicates a supported image format

func ReadImageToProviderData

func ReadImageToProviderData() (*provider.ImageData, error)

ReadImageToProviderData reads clipboard image directly to provider.ImageData

Types

type ImageInfo

type ImageInfo struct {
	Path      string
	MediaType string
	Data      []byte
	Size      int
	FileName  string
}

ImageInfo holds information about a loaded image

func Load

func Load(path string) (*ImageInfo, error)

Load loads and validates an image from the given path

func ReadImageFromClipboard

func ReadImageFromClipboard() (*ImageInfo, error)

ReadImageFromClipboard reads an image from the clipboard. Returns nil, nil if no image is available (not an error).

func (*ImageInfo) ToBase64

func (i *ImageInfo) ToBase64() string

ToBase64 returns the image data as a base64 encoded string

func (*ImageInfo) ToProviderData

func (i *ImageInfo) ToProviderData() provider.ImageData

ToProviderData converts ImageInfo to provider.ImageData

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL