# Direct Image URL: What It Is, How to Check

> A direct image URL returns the image file itself, not a page that shows it. How to get one, check it with curl, and pass it to a reverse image search API.

[Home](https://quanticdata.io/) / [Blog](https://quanticdata.io/blog/) / Direct Image URL: What It Is, How to Check

# Direct image URL: what it is, how to get one and how to check it

SERP & search · Nov 20, 2026 · 6 min read · By [Aldo Morese](https://quanticdata.io/about/), founder of QuanticData

![Two addresses for the same picture: a direct image URL answers with content type image/jpeg and a reverse image search returned 10 matches for it, while the address of the page that shows the picture answers with text/html; the card lists the three things a direct image URL must do.](https://quanticdata.io/blog/direct-image-url/hero.webp?v=20261120h)

On this page

- [Direct image URL or page URL: how to tell](https://quanticdata.io/blog/direct-image-url/#direct-image-url-or-page-url-how-to-tell)
- [How to get a direct image URL](https://quanticdata.io/blog/direct-image-url/#how-to-get-a-direct-image-url)
- [Passing the URL to a reverse image search API](https://quanticdata.io/blog/direct-image-url/#passing-the-url-to-a-reverse-image-search-api)
- [What the API does with each kind of URL](https://quanticdata.io/blog/direct-image-url/#what-the-api-does-with-each-kind-of-url)
- [A checker to run before a batch](https://quanticdata.io/blog/direct-image-url/#a-checker-to-run-before-a-batch)
- [Which endpoint to use](https://quanticdata.io/blog/direct-image-url/#which-endpoint-to-use)

A direct image URL is an address that returns the image file itself: open it and the browser shows only the picture, and the server's `Content-Type` starts with `image/`. The address of a web page that displays the picture is not direct: it returns HTML. Tools that take an "image URL", from forums to reverse image search APIs, want the first kind.

**Run it on the free credit.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-lead&utm_content=direct-image-url) · [Explore SERP API](https://quanticdata.io/serp-api/)

The checks and API calls below were run on 20 November 2026. The API is the QuanticData [reverse image search endpoint](https://quanticdata.io/serp-api/google/lens/), which takes an `image_url` and returns the pages where that picture appears.

## Direct image URL or page URL: how to tell

|  | Direct image URL | Page URL |
| --- | --- | --- |
| What the server returns | The image bytes | An HTML document |
| Content-Type | `image/jpeg`, `image/png`, `image/webp`... | `text/html` |
| In a browser tab | Only the picture, on a plain background | The picture with a site around it |
| Usual look | Often ends in .jpg, .png, .webp | Often has /photo/, /details/, /view/ or an id |

The file extension is a hint, not proof. Some image addresses have no extension, and some addresses that end in .jpg return a viewer page. The header is what counts, and one command reads it:

```bash
$ curl -s -o /dev/null -w "%{http_code} %{content_type}\n" "https://images-assets.nasa.gov/image/PIA18033/PIA18033~medium.jpg"
200 image/jpeg

$ curl -s -o /dev/null -w "%{http_code} %{content_type}\n" "https://images.nasa.gov/details/PIA18033"
200 text/html
```

Both addresses lead to the same NASA picture. The first is the file; the second is the page that presents it. If the status is not 200, the host is refusing the request, and anything you hand that address to will be refused as well. More on reading headers is in [reading response headers with curl](https://quanticdata.io/blog/curl-headers/).

## How to get a direct image URL

- **From a web page:** right-click the picture and choose "Open image in new tab", then copy the address of that tab. "Copy image address" gives the same result. On a phone, press and hold the picture and choose the option to open or copy the image.
- **From the page source:** look for the `og:image` meta tag in the page's head. It is the picture the site offers to link previews, with a full address.
- **From a photo host:** use the link the host labels "direct link". The default share link usually opens a viewer page.
- **From cloud storage:** a share link from a drive service opens a preview page, not the file. Use a host that serves the file itself, or put the image on your own site or bucket with public read access.
- **From your computer:** a file on disk has no URL. Upload it somewhere public first, then run the curl check on the address you get.

Then verify with a private browser window. If the picture loads there, with no login and no cookie from your own session, a server on the other side of the world can load it too.

## Passing the URL to a reverse image search API

A reverse image search starts from a picture and returns the pages that contain it. With the [SERP API](https://quanticdata.io/serp-api/) it is one request: `search_type` set to `lens` and the picture's address in `image_url`.

```bash
$ curl -s -X POST https://api.quanticdata.io/v1/scraper/serp \
    -H "Authorization: Bearer $QD_API_KEY" -H "Content-Type: application/json" \
    -d '{"search_type":"lens","image_url":"https://images-assets.nasa.gov/image/PIA18033/PIA18033~medium.jpg","country":"us"}'
{"type":"response","message":"SERP successful","payload":{
 "search_parameters":{"q":"https://images-assets.nasa.gov/image/PIA18033/PIA18033~medium.jpg","search_type":"reverse_image","device":"desktop","country":"us","page":1},
 "visual_matches":[
  {"rank":1,"title":"13 \"golpes de sorte\" que permitiram o surgimento da vida na Terra",
   "link":"https://hypescience.com/13-golpes-de-sorte-que-permitiram-o-surgimento-da-vida-na-terra/?amp=1",
   "source":"hypescience.com","domain":"hypescience.com",
   "image":"https://hypescience.com/wp-content/uploads/2012/07/blue-earth.jpg", ...},
  ... 9 more matches]}}
```

Ten matches came back, each with the page's title and link, its domain and the address of the matching image on that page. The answer labels the search `reverse_image`; `lens` and `reverse_image` are two names for the same search type.

**Try it on your own targets.** Every QuanticData account gets $2 of free API usage per month.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-inline&utm_content=direct-image-url) · [Explore SERP API](https://quanticdata.io/serp-api/)

## What the API does with each kind of URL

We sent four requests that differ only in `image_url`:

| `image_url` | Answer | What happened |
| --- | --- | --- |
| A direct JPEG address | 200, 10 matches | The file was searched |
| A page that declares `og:image` (a Wikipedia article) | 200, matches for the preview image | The page's `og:image` was used as the picture |
| A page with no `og:image` | 422, code `image-is-page` | The message asks for the direct link |
| No `image_url` at all | 400 | The message says the field is required |

The second row is a convenience: when you pass a page, the API searches the page's preview image. On the article we tried, the preview image was a logo drawing, not the photograph most people would mean. If you care which picture is searched, send its direct address.

The 422 for a page without a preview image reads:

```json
{"type":"error","message":"image_url is a web page, not an image, and the page declares no og:image — pass the direct link to the image file",
 "payload":{"code":"image-is-page"}}
```

The answer carries a code in `payload.code`, here `image-is-page`, so a program can react without parsing the sentence. The request with no `image_url` answered 400 with a message that says the field is required and must be a publicly reachable http or https address that serves the image itself. The API reference describes the field in one line: the http(s) URL of the image to search by.

## A checker to run before a batch

If you are about to send hundreds of addresses, check them first and fix the ones that are pages. This Python function applies the same test as the curl command:

```python
import requests

def is_direct_image(url):
    r = requests.get(url, stream=True, timeout=20, headers={"Accept": "image/*,*/*;q=0.8"})
    kind = r.headers.get("Content-Type", "").split(";")[0]
    r.close()
    return r.status_code == 200 and kind.startswith("image/"), r.status_code, kind

for url in ["https://images-assets.nasa.gov/image/PIA18033/PIA18033~medium.jpg",
            "https://images.nasa.gov/details/PIA18033"]:
    print(is_direct_image(url), url)
```

```
(True, 200, 'image/jpeg') https://images-assets.nasa.gov/image/PIA18033/PIA18033~medium.jpg
(False, 200, 'text/html') https://images.nasa.gov/details/PIA18033
```

It uses GET with `stream=True` and closes the connection after the headers, because some hosts answer HEAD requests differently from GET. For saving the files themselves, see [downloading images with Python](https://quanticdata.io/blog/scrape-images-python/).

## Which endpoint to use

The call above returns the matches of one search. If you would rather give a list of pictures and receive rows, the [reverse image search collector](https://quanticdata.io/collectors/reverse-image-search-api/) wraps the same search as a collector run with a cap per run. Parameters such as `country`, `lang` and `exact_matches` are in the [API reference](https://quanticdata.io/docs/).

### Sources & further reading

- [MDN: Content-Type header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Content-Type)
- [MDN: Image file type and format guide](https://developer.mozilla.org/en-US/docs/Web/Media/Guides/Formats/Image_types)
- [The Open Graph protocol (og:image)](https://ogp.me/)
- [NASA Image and Video Library: PIA18033](https://images.nasa.gov/details/PIA18033)
- [curl manual: -w, --write-out](https://curl.se/docs/manpage.html#-w)

## FAQ

Quick answers on direct image URL.

[Something else? Ask us](mailto:hello@quanticdata.io)

### What is a direct image URL?

An address that returns the image file itself. The server answers with a `Content-Type` that starts with `image/`, and a browser tab shows only the picture. A page that displays the picture returns `text/html` and is not a direct image URL.

### How do I get the direct URL of an image?

Right-click the picture and choose "Open image in new tab" or "Copy image address". On photo hosts use the link labelled "direct link". Then check it with `curl -s -o /dev/null -w "%{http_code} %{content_type}" URL`: you want 200 and an image type.

### Does a direct image URL have to end in .jpg or .png?

No. The extension is only a hint. What matters is the Content-Type the server sends; some image addresses have no extension at all, and some addresses ending in .jpg return a viewer page.

### Can I pass a page URL to the reverse image search API?

If the page declares an `og:image`, the API searches that picture: our test with a Wikipedia article returned 200 with matches for the article's preview image. A page with no `og:image` answers 422 with the code `image-is-page`. To choose the picture yourself, send its direct address.

### Why does my image URL work in my browser but not in an API?

Usually because your browser is logged in or sends a cookie the host requires, or the host only serves the file to its own pages. Test the address in a private window and with curl; if it does not return 200 and an image type there, host the picture somewhere public.

## Search the web by picture

Send a direct image URL, get back the pages where the picture appears, as JSON.

[Start free — $2/month included](https://quanticdata.io/signup/?utm_source=blog&utm_medium=website&utm_campaign=blog-end&utm_content=direct-image-url) · [Explore SERP API](https://quanticdata.io/serp-api/)

## Collectors for this data

- [Google Images scraper API](https://quanticdata.io/collectors/image-scraper-api/): Collector · Google Images results for a query — thumbnail, source page and host.

## Related reading

- [SERP API Benchmark: Google, Bing, DuckDuckGo](https://quanticdata.io/blog/serp-api-benchmark-tested/): SERP & search · We sent the same 40 queries to Google, Bing and DuckDuckGo through our SERP API on 4 October 2026 and kept every row. 117 of 120 calls returned a full results page on the first attempt, the median call took 2.92 seconds, and the three engines returned different blocks: AI Overviews on 21 of 38 Google pages, inline videos on 21 of 39 Bing pages. 1,000 searches cost $0.50 on Bing or DuckDuckGo and $2 on Google.
- [How to Scrape Google Reviews: 800 Measured](https://quanticdata.io/blog/scrape-google-reviews/): SERP & search · On 7 October 2026 we pulled the 100 newest Google reviews of 8 US places through one API call each: 800 of 800 delivered, every row with rating, ISO date and review id. Here is the Python code, what the rows contain, how fast reviews pile up, and what it costs.
- [Scrape Google Search Results in Python, Tested](https://quanticdata.io/blog/scrape-google-search-results-python/): SERP & search · On 8 October 2026 we ran 10 Google searches from a Python script through one API endpoint: 100 of 100 organic results came back with title, link and snippet, in a median 3.5 seconds per call. Here is the code, why the classic BeautifulSoup tutorial returns nothing, and what it costs.

---

Source: https://quanticdata.io/blog/direct-image-url/ · Site index for AI: https://quanticdata.io/llms.txt
