• Stars
    star
    139
  • Rank 262,954 (Top 6 %)
  • Language
    Go
  • License
    BSD 2-Clause "Sim...
  • Created over 8 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ”ณ Gracefully handle image uploading and thumbnail creation.

go-imageupload

GoDoc

๐Ÿ”ณ Gracefully handle image uploading and thumbnail creation.

Install

go get github.com/olahol/go-imageupload

Example

Thumbnail creator.

package main

import (
	"net/http"

	"github.com/olahol/go-imageupload"
)

func main() {
	http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
		http.ServeFile(w, r, "index.html")
	})

	http.HandleFunc("/upload", func(w http.ResponseWriter, r *http.Request) {
		if r.Method != "POST" {
			http.NotFound(w, r)
			return
		}

		img, err := imageupload.Process(r, "file")

		if err != nil {
			panic(err)
		}

		thumb, err := imageupload.ThumbnailPNG(img, 300, 300)

		if err != nil {
			panic(err)
		}

		thumb.Write(w)
	})

	http.ListenAndServe(":5000", nil)
}
<html>
<body>
  <form method="POST" action="/upload" enctype="multipart/form-data">
    <input type="file" name="file">
    <input type="submit">
  </form>
</body>
</html>

Contributors

  • Ola Holmstrรถm (@olahol)
  • Shintaro Kaneko (@kaneshin)

Documentation

More Repositories

1

melody

๐ŸŽถ Minimalist websocket framework for Go
Go
3,685
star
2

react-tagsinput

Highly customizable React component for inputing tags.
JavaScript
1,345
star
3

reactpack

๐Ÿ“ฆ build your react apps with one command and one `npm i`.
JavaScript
982
star
4

melody-jsnes

๐Ÿ“บ Multiplayer NES through the magic of WebSockets and Go.
HTML
767
star
5

react-ab

Simple declarative and universal A/B testing component for React.
JavaScript
432
star
6

react-social

Simple React components for social buttons (Facebook, Twitter and Pinterest) and social counts.
HTML
177
star
7

iso-3166-2.js

Lookup information about ISO-3166-2 subdivisions
JavaScript
108
star
8

express-chrome-logger

Debug your express app using the Chrome console.
JavaScript
83
star
9

pocketplace

๐ŸŽ† Draw pixels on a canvas with friends.
Go
79
star
10

scrollparent.js

A function to get the scrolling parent of a html element.
HTML
58
star
11

node-csp

Communicating sequential processes for node.
JavaScript
55
star
12

iso-3166-2.json

JSON file of ISO 3166-2 subdivisions.
JavaScript
54
star
13

greasyphone

๐Ÿ“ฑ ๐ŸŽฎ Play NES using smartphones as joypads
JavaScript
45
star
14

viewdiff

๐Ÿ“’ view your diffs in a separate window.
JavaScript
41
star
15

bf2c

๐Ÿ› Not the smallest compiler ever
JavaScript
20
star
16

socialcount.js

Tiny javascript library for getting social share counts. Pinterest, Facebook, Twitter and Google Plus supported.
JavaScript
17
star
17

cpp-csp

Minimalistic header-only library for channels and CSP (Communicating sequential process) in C++11.
C++
15
star
18

ethereum-web1-guestbook

๐Ÿ““ A Web 1.0 guestbook on Web 3.0
HTML
15
star
19

mainthread

Run functions in Go's main thread.
Go
14
star
20

eselement

DOM-like wrapper around the Javascript AST
JavaScript
6
star
21

tsreflect

Flexible reflection based TypeScript type generator for Go types that can be marshalled with `encoding/json`.
Go
6
star
22

capreq

Capture HTTP Requests using gopacket and libpcap
Go
6
star
23

hnplain

output Hacker News in plain text
Python
6
star
24

react-bus

Event emitter designed for communication between react components.
JavaScript
5
star
25

bf2asmjs

A simple brainfuck compiler targeting asm.js
Python
5
star
26

spawn.js

Tiny javascript library for spinning up one off web workers.
JavaScript
3
star
27

node-crcaptcha

Node package for using the Civil Rights Captcha.
JavaScript
2
star
28

tiny-xss-scanner

Lighweight xss scanner
Python
2
star
29

olapass

Stateless password manager.
JavaScript
1
star
30

request-animation-loop

As setInterval is to setTimeout, requestAnimationLoop is to requestAnimationFrame.
JavaScript
1
star
31

cpp-project-template

A small template for C++11 projects using tup and clang.
C++
1
star
32

generator-react-umd

A Yeoman generator that generates a minimalistic scaffold for a ES6 React component wrapped with the UMD.
JavaScript
1
star
33

gin-csrf

CSRF protection middleware for Go web framework Gin
Go
1
star
34

deepmodules

Analyze depth of Go packages
Go
1
star
35

node-mysql-slowlog

Application level slow log for mysql connections. Good for debugging slow queries when you haven't turned on or have access to the database slow log.
JavaScript
1
star