400/animate

clip rectangle must fit within viewport

How to fix the Scrnpix API error when the clip rectangle extends beyond the viewport dimensions in an animate request.

When Does This Happen?

This error occurs when the clip rectangle defined by clip_x, clip_y, clip_width, and clip_height extends beyond the viewport boundaries. The sum of clip_x + clip_width must not exceed the viewport width, and clip_y + clip_height must not exceed the viewport height.

Reproduce This Error

curl -H "X-KEY: your-api-key" \
  "https://api.scrnpix.com/animate?url=https%3A%2F%2Fexample.com&clip=true&clip_x=700&clip_width=400&clip_height=300&width=800"
clip rectangle must fit within viewport

How to Fix

  1. 1Ensure clip_x + clip_width does not exceed the viewport width
  2. 2Ensure clip_y + clip_height does not exceed the viewport height
  3. 3Increase the viewport width/height if you need a larger clip area
  4. 4Adjust clip_x/clip_y offsets to keep the rectangle within bounds

Correct Request

curl -H "X-KEY: your-api-key" \
  "https://api.scrnpix.com/animate?url=https%3A%2F%2Fexample.com&clip=true&clip_x=100&clip_width=400&clip_height=300&width=800&height=600" \
  --output animation.gif
200 OK — returns the clipped animation as a GIF

Related Errors

Frequently Asked Questions

How do I calculate valid clip dimensions?

The clip rectangle must satisfy: clip_x + clip_width <= viewport width AND clip_y + clip_height <= viewport height. For example, with a default 800x600 viewport, clip_x=200 and clip_width=600 is valid (200+600=800), but clip_x=200 and clip_width=700 would exceed the viewport (200+700=900 > 800).

Still Having Issues?

Check your API key and subscription status in the dashboard, or explore our language guides for integration examples.

Go to Dashboard