Screenshot API error ยท HTTP 422

Image does not fit max_file_size

max_file_size_unreachable

No encoding of the image fits max_file_size: not at the lowest quality, not with the fewest colours and not scaled down to a quarter of its size.

How to recognize it

The API answers with status 422 and a JSON body with the message and the error.code max_file_size_unreachable, for example:

HTTP/1.1 422
Content-Type: application/json

{
  "error": {
    "code": "max_file_size_unreachable",
    "message": "The image does not fit max_file_size, not even at the lowest quality, with the fewest colours and at a quarter of its size. Raise max_file_size, or ask for a smaller image_width/image_height or another format."
  },
  "message": "The image does not fit max_file_size, not even at the lowest quality, with the fewest colours and at a quarter of its size. Raise max_file_size, or ask for a smaller image_width/image_height or another format."
}

Common causes

  • A max_file_size too small for the image, such as a full-page screenshot or a large viewport in a few kilobytes.
  • A page full of photos as png or gif, which can only reduce colours, not quality.

How to fix it

  1. Raise max_file_size.
  2. Ask for a smaller image with image_width and image_height, or capture a smaller viewport.
  3. Use format=jpg, webp or avif, which lower the quality first. A successful response says the quality used in X-Final-Quality.

Billing

Not billed: a request answered with this error does not count against your quota. One exception: when an evaluate step of actions or the scripts ran in the page before the render failed, it is billed as one request, because that code could read the page, unless the failure is ours.

Related parameters

max_file_size, image_width, image_height, format. Each is described in the take endpoint reference.

Every response carries an X-Request-Id header. If this page does not explain the error, write to support@screenshotbase.com with that id. All statuses: status codes.

Other API errors

Screenshot API

Take screenshots from your code

screenshotbase renders any website in a real browser and returns the image: full page or viewport, any device size, retina, from 100+ countries, with cookie banners and ads hidden.

/v1/take documentation Screenshot API All documentation

300 free screenshots every month. No credit card required.

GET https://api.screenshotbase.com/v1/take?url=https://example.com&full_page=true

# Response: the image (PNG, JPG, WebP, AVIF or GIF)
curl -G "https://api.screenshotbase.com/v1/take" \
  --data-urlencode "url=https://example.com" \
  -d viewport_width=1280 -d viewport_height=800 \
  -d format=png \
  -H "apikey: YOUR-API-KEY" \
  -o screenshot.png

More free tools

Start using our Screenshot API for free today!

Get 300 requests / month for free