Пример #1
0
func handlerImage(res http.ResponseWriter, req *http.Request) {
	params := mux.Vars(req)
	width, err := strconv.Atoi(params["width"])
	height, err := strconv.Atoi(params["height"])
	size := width * height

	if err != nil || size <= 0 || size > 1000000 {
		res.WriteHeader(http.StatusBadRequest)
		return
	}

	img := lorempixum.GetImage(width, height)
	lorempixum.StreamImage(res, img, params["format"])
}
Пример #2
0
func main() {
	img := lorempixum.GetImage(100, 100)
	lorempixum.StreamImage(os.Stdout, img, "jpeg")
}