Tool Command Language

Capture screenshots in Tcl

Add screenshot and scrolling GIF capabilities to your Tcl applications with the http package. Perfect for Tk GUIs and automation scripts.

Installation

  1. 1http and tls packages are included in Tcl distribution
  2. 2Get your API key from the dashboard
  3. 3Set the X-KEY header in your requests

Authentication

Include your API key in the X-KEY header with every request:

package require http
package require tls
http::register https 443 ::tls::socket

set token [http::geturl $url -headers [list X-KEY "your-api-key"]]
set data [http::data $token]

Tcl Screenshot Example

Capture a screenshot or create a scrolling GIF animation with a simple GET request:

Screenshot
package require http
package require tls

::http::register https 443 ::tls::socket

set token [::http::geturl "https://api.scrnpix.com/screenshot?url=https%3A%2F%2Fexample.com&width=1280&height=720&format=png" \
    -headers {X-KEY your-api-key}]

set fp [open "screenshot.png" wb]
puts -nonewline $fp [::http::data $token]
close $fp
Animation
package require http
package require tls

::http::register https 443 ::tls::socket

set token [::http::geturl "https://api.scrnpix.com/animate?url=https%3A%2F%2Fexample.com&scroll_duration=3000&scroll_easing=ease-in-out" \
    -headers {X-KEY your-api-key}]

set fp [open "animation.gif" wb]
puts -nonewline $fp [::http::data $token]
close $fp

Response Format

On success, the API returns the image binary data directly in the response body.

Status Code200 OK
Content-Typeimage/png, image/jpeg, or image/gif
BodyBinary image data
Error ResponseError message with 4xx/5xx status

Key Features

Zero Setup

http and tls packages are included in Tcl. No browser installations required.

Production Ready

Built on Cloudflare Workers with global edge network. Handles concurrency and browser lifecycle automatically.

Tcl Integration

Works with Tk for GUI display. Perfect for automation scripts, expect, or embedded Tcl applications.

Rich Features

Custom viewport sizes, full page capture, PNG/JPEG formats, scrolling GIFs with 15 easing functions.

Frequently Asked Questions

Do I need to install any browser dependencies for Tcl?

No. Scrnpix runs browsers on our infrastructure. You only need Tcl's http and tls packages.

Can I display screenshots in Tk?

Yes. Use the Img package to load the binary data and display in a Tk canvas or label widget.

How do I handle errors in Tcl?

Check http::status and http::ncode for the response status. Use catch for error handling.

What Tcl version is required?

Tcl 8.5+ with http and tls packages. The API is a simple HTTP GET request.

Ready to capture screenshots in Tcl?

Get your API key and start rendering screenshots in seconds. Free tier includes 50 screenshots per month.

Start Free