Fix GetImageSizeFromUrl for image url without Content-Type

This commit is contained in:
WqyJh 2024-02-27 20:28:07 +08:00
parent b747cdbc6f
commit 052092391d

View File

@ -16,7 +16,7 @@ import (
)
// Regex to match data URL pattern
var dataURLPattern = regexp.MustCompile(`data:image/([^;]+);base64,(.*)`)
var dataURLPattern = regexp.MustCompile(`data:image/([^;]+);base64,(.*)`)
func IsImageUrl(url string) (bool, error) {
resp, err := http.Head(url)
@ -30,10 +30,6 @@ func IsImageUrl(url string) (bool, error) {
}
func GetImageSizeFromUrl(url string) (width int, height int, err error) {
isImage, err := IsImageUrl(url)
if !isImage {
return
}
resp, err := http.Get(url)
if err != nil {
return