func ReadImageFromURL(ctx context.Context, url string) ([]byte, error) {
	client := &http.Client{
		Transport: &http.Transport{ // ignore insecure certificates
			TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
		},

		Timeout: imageGetTimeout,
	}

	req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
	if err != nil {
		return nil, err
	}

	// assume is a URL for now

	// set the host of the URL as the referer
	if req.URL.Scheme != "" {
		req.Header.Set("Referer", req.URL.Scheme+"://"+req.Host+"/")
	}
	req.Header.Set("User-Agent", getUserAgent())

	resp, err := client.Do(req)

	if err != nil {
		return nil, err
	}

	if resp.StatusCode >= 400 {
		return nil, fmt.Errorf("http error %d", resp.StatusCode)
	}

	defer resp.Body.Close()

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}

	return body, nil
}
// ReadImageFromURL returns image data from a URL
ReadImageFromURL returns image data from a URL
// ReadImageFromURL returns image data from a URL
func ReadImageFromURL(ctx context.Context, url string) ([]byte, error) {
	client := &http.Client{
		Transport: &http.Transport{ 
			TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
		},
		Timeout: imageGetTimeout,
	}
	req, err := http.NewRequestWithContext(ctx, http.MethodGet, url, nil)
	if err != nil {
		return nil, err
	}
	if req.URL.Scheme != "" {
		req.Header.Set("Referer", req.URL.Scheme+"://"+req.Host+"/")
	}
	req.Header.Set("User-Agent", getUserAgent())
	resp, err := client.Do(req)
	if err != nil {
		return nil, err
	}
	if resp.StatusCode >= 400 {
		return nil, fmt.Errorf("http error %d", resp.StatusCode)
	}
	defer resp.Body.Close()
	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, err
	}
	return body, nil
}
func ReadImageFromURL ( ctx context . Context , url string ) ( [ ] byte , error ) { client := & http . Client { Transport : & http . Transport { TLSClientConfig : & tls . Config { InsecureSkipVerify : true } , } , Timeout : imageGetTimeout , } req , err := http . NewRequestWithContext ( ctx , http . MethodGet , url , nil ) if err != nil { return nil , err } if req . URL . Scheme != " " { req . Header . Set ( " " , req . URL . Scheme + " " + req . Host + " " ) } req . Header . Set ( " " , getUserAgent ( ) ) resp , err := client . Do ( req ) if err != nil { return nil , err } if resp . StatusCode >= 400 { return nil , fmt . Errorf ( " " , resp . StatusCode ) } defer resp . Body . Close ( ) body , err := io . ReadAll ( resp . Body ) if err != nil { return nil , err } return body , nil }
ReadImageFromURL returns image data from a URL
ReadImageFromURL returns image data from a URL
// ignore insecure certificates // assume is a URL for now // set the host of the URL as the referer