Files
request/v3/image.go
Matheus Sampaio Queiroga 59f42ea7e6
All checks were successful
Golang test / go-test (push) Successful in 1m9s
Create new v3 package and deprected v2
2025-10-19 01:05:24 -03:00

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
}