olahol / Go Imageupload
🔳 Gracefully handle image uploading and thumbnail creation.
Stars: ✠131
Programming Languages
go
31211 projects - #10 most used programming language
go-imageupload
🔳 Gracefully handle image uploading and thumbnail creation.
Install
go get github.com/olahol/go-imageupload
Example
Thumbnail creator using Gin.
package main
import (
"github.com/gin-gonic/gin"
"github.com/olahol/go-imageupload"
)
func main() {
r := gin.Default()
r.GET("/", func(c *gin.Context) {
c.File("index.html")
})
r.POST("/upload", func(c *gin.Context) {
img, err := imageupload.Process(c.Request, "file")
if err != nil {
panic(err)
}
thumb, err := imageupload.ThumbnailPNG(img, 300, 300)
if err != nil {
panic(err)
}
thumb.Write(c.Writer)
})
r.Run(":5000")
}
<html>
<body>
<form method="POST" action="/upload" enctype="multipart/form-data">
<input type="file" name="file">
<input type="submit">
</form>
</body>
</html>
Contributors
Documentation
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].