Skip to content

[FEATURE] Image Processing Utilities (imageutils) #152

@kashifkhan0771

Description

@kashifkhan0771

Feature Description

Image processing is essential for modern applications dealing with user uploads, content management, and media optimization. We should extend our library to have image processing utilities.


Use Case

Image processing utilities can be used in many applications dealing with users and content-management.


Proposed Solution

At top level we should follow our library structure.


Additional Context

Check Pseudo Code section


Pseudo Code

type Image struct {
    Data   []byte
    Format ImageFormat
    Width  int
    Height int
    
    // Metadata
    ColorProfile string
    DPI          int
    Quality      int
}

type ImageFormat int

const (
    FormatJPEG ImageFormat = iota
    FormatPNG
    FormatGIF
    FormatWEBP
    FormatBMP
    FormatTIFF
    FormatSVG
    FormatICO
    FormatAVIF
    FormatHEIF
)

// Load image from various sources
func LoadFromFile(filepath string) (*Image, error)
func LoadFromBytes(data []byte) (*Image, error)
func LoadFromURL(url string) (*Image, error)
func LoadFromReader(reader io.Reader) (*Image, error)

// Save image to various destinations
func (img *Image) SaveToFile(filepath string) error
func (img *Image) SaveToWriter(writer io.Writer, format ImageFormat) error
func (img *Image) ToBytes(format ImageFormat) ([]byte, error)
func (img *Image) ToBase64(format ImageFormat) (string, error)

// Common resize operations
func (img *Image) ResizeToWidth(width int) (*Image, error)
func (img *Image) ResizeToHeight(height int) (*Image, error)
func (img *Image) ResizeToFit(maxWidth, maxHeight int) (*Image, error)
func (img *Image) ResizeToFill(width, height int) (*Image, error)

// Scale operations
func (img *Image) Scale(factor float64) (*Image, error)
func (img *Image) ScaleDown(maxWidth, maxHeight int) (*Image, error)

// More utilities can be added as per choice

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requesthelp wantedExtra attention is neededlarge-enhancementA major feature or addition to existing functionality, requiring significant effort or changes

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions