Categorygithub.com/rayne22/file-processor
modulepackage
0.0.0-20210618082129-1b904864314d
Repository: https://github.com/rayne22/file-processor.git
Documentation: pkg.go.dev

# README

File Processor

A GO library for manipulating and processing images

GoDoc GoDoc Gitter License: MIT FOSSA Status

Prerequisites

This package needs at least Go 1.15.6

Installation

 go get -u github.com/rayne22/file-processor

Easy right...

Usage

Import package using

import "github.com/rayne22/file-processor/process"

Image Resizing

  • process.ResizeImage produces a scaled image based on the width and height provided using the interpolation. If there is need to preserve the aspect ratio, the width or height can be set to 0.
Struct
type UploadedImage struct {
	Path        string `json:"path"`
	ImageName   string `json:"image_name"`
	Width       uint   `json:"width"`
	Height      uint   `json:"height"`
	Request     multipart.File
	ImageHeader *multipart.FileHeader
}
Function
func (u *UploadedImage) ResizeImage() string 

Example


processor := process.UploadedImage{}  //Initializing the Struct


processor.Height = 200  // Adding height
processor.Width = 200  // Adding width
processor.Path = "temp"  // Adding temporary image storage directory

processor.Request = file //  If image is being posted through a form, the file is stored in this field
processor.ImageHeader = fileHeader // If image is being posted through a form, the fileHeader is stored in this field

_= processor.ResizeImage() // Function for resizing images

NB: The above code should be inside a function

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

FOSSA Status

# Packages

No description provided by the author