request/v2/image.go
Matheus Sampaio Queiroga df0d1980f0 Delete request/v1 and Refactor request/{v2,gohtml} (#28)
Co-authored-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
Co-committed-by: Matheus Sampaio Queiroga <srherobrine20@gmail.com>
2025-02-27 15:03:57 +00:00

35 lines
926 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(Url string, RequestOption *Options) (image.Image, string, *http.Response, error) {
res, err := Request(Url, RequestOption)
if err != nil {
return nil, "", nil, err
}
defer res.Body.Close()
imageDecode, imageType, err := image.Decode(res.Body)
return imageDecode, imageType, res, err
}
// Make request and return [image.DecodeConfig]
//
// Require import modules to [image.DecodeConfig], see [image] to more info
func ImageConfig(Url string, RequestOption *Options) (image.Config, string, *http.Response, error) {
res, err := Request(Url, RequestOption)
if err != nil {
return image.Config{}, "", nil, err
}
defer res.Body.Close()
imageDecode, imageType, err := image.DecodeConfig(res.Body)
return imageDecode, imageType, res, err
}