All checks were successful
Golang test / go-test (push) Successful in 1m9s
33 lines
823 B
Go
33 lines
823 B
Go
package request
|
|
|
|
import (
|
|
"image"
|
|
"net/http"
|
|
)
|
|
|
|
// Make request and return [image.Image]
|
|
//
|
|
// Require import modules to [image.Decode], see [image] to more info
|
|
func Image[T InputUrl](urlInput T, opt *Options) (img image.Image, imgType string, res *http.Response, err error) {
|
|
if res, err = Request(urlInput, opt); err != nil {
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
img, imgType, err = image.Decode(res.Body)
|
|
return
|
|
}
|
|
|
|
// Make request and return [image.DecodeConfig]
|
|
//
|
|
// Require import modules to [image.DecodeConfig], see [image] to more info
|
|
func ImageConfig[T InputUrl](urlInput T, opt *Options) (img image.Config, imgType string, res *http.Response, err error) {
|
|
if res, err = Request(urlInput, opt); err != nil {
|
|
return
|
|
}
|
|
defer res.Body.Close()
|
|
|
|
img, imgType, err = image.DecodeConfig(res.Body)
|
|
return
|
|
}
|