pictomancer
Python SDK for Pictomancer.ai — a thin httpx wrapper around the REST API at https://api.pictomancer.ai.
Install
pip install .
From PyPI (when published):
pip install pictomancer
Configuration
api_key— optional Bearer token (Authorization: Bearer …).base_url— defaults tohttps://api.pictomancer.ai.timeout— request timeout in seconds (default30.0).
JSON helpers return dict; image operations return bytes (response body).
Synchronous client
from pictomancer import Client
with Client(api_key="your-api-key") as client:
info = client.info()
usage = client.usage()
meta = client.analyze("https://example.com/image.jpg")
out = client.resize("https://example.com/image.jpg", scale=0.5, format="webp")
out = client.compress("https://example.com/image.jpg", q=85, format="jpeg")
out = client.convert("https://example.com/image.jpg", "png", q=90)
out = client.crop("https://example.com/image.jpg", 0, 0, 100, 100, format="webp")
out = client.pipeline(
"https://example.com/image.jpg",
[
{"type": "resize", "params": {"scale": "0.5"}},
{"type": "convert", "params": {"format": "webp"}},
],
)
with open("out.webp", "wb") as f:
f.write(out)
Async client
import asyncio
from pictomancer import AsyncClient
async def main():
async with AsyncClient(api_key="your-api-key") as client:
info = await client.info()
usage = await client.usage()
meta = await client.analyze("https://example.com/image.jpg")
out = await client.resize("https://example.com/image.jpg", scale=0.5, format="webp")
return info, usage, meta, out
asyncio.run(main())
Delivery: write the result somewhere else
By default an operation returns the optimized bytes. Pass a delivery target to
have Pictomancer write the result directly to your storage or endpoint instead —
the operation then returns a dict (etag, sha256, bytes written, ...). No cloud
credentials ever reach Pictomancer.
from pictomancer import Client, PutUrl, Callback
with Client(api_key="your-api-key") as client:
# Upload to a customer-signed presigned PUT URL (S3/R2/GCS/Azure).
res = client.resize(
"https://example.com/image.jpg",
scale=0.5,
delivery=PutUrl("https://bucket.s3.amazonaws.com/key?X-Amz-Signature=..."),
)
print(res["sha256"], res["bytes_written"])
# Or POST the bytes to your own callback endpoint (async/large jobs).
res = client.compress(
"https://example.com/image.jpg",
delivery=Callback("https://hooks.example.com/pig?token=secret"),
)
print(res["status"], res["sha256"])
PutUrl and Callback accept optional headers= (whitelisted storage headers,
e.g. Content-Type, Cache-Control, x-amz-*). The returned sha256 is the
digest of exactly the bytes delivered, so you can verify the stored object.
Authenticating a callback
Pass secret= to Callback to have the POST body signed. We send
X-Pig-Signature: sha256=<hex> (HMAC-SHA256 of the body, GitHub-webhook style).
The secret is used per request and never stored. Verify it on your endpoint:
res = client.resize(
"https://example.com/image.jpg",
scale=0.5,
delivery=Callback("https://hooks.example.com/pig", secret="shared-secret"),
)
# On your endpoint (any framework), recompute and constant-time compare:
import hashlib, hmac
expected = "sha256=" + hmac.new(b"shared-secret", request_body, hashlib.sha256).hexdigest()
assert hmac.compare_digest(expected, request.headers["X-Pig-Signature"])
Errors use httpx behavior: non-2xx responses raise httpx.HTTPStatusError after raise_for_status().
API documentation
Interactive docs: https://api.pictomancer.ai/docs
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pictomancer-0.2.0.tar.gz.
File metadata
- Download URL: pictomancer-0.2.0.tar.gz
- Upload date:
- Size: 4.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b319a8e932a34f9f6a0253d8edd8d81455522e6acc98dcd50fbf5beabdbb4b8
|
|
| MD5 |
cf74b1b7bc0b353445f882c9161ca6b0
|
|
| BLAKE2b-256 |
51489ae3c432151c2dad6a77efa64d831ac8e96ea11bb9090b5701f39f597aa4
|
Provenance
The following attestation bundles were made for pictomancer-0.2.0.tar.gz:
Publisher:
publish.yml on pictomancer/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pictomancer-0.2.0.tar.gz -
Subject digest:
1b319a8e932a34f9f6a0253d8edd8d81455522e6acc98dcd50fbf5beabdbb4b8 - Sigstore transparency entry: 2201666139
- Sigstore integration time:
-
Permalink:
pictomancer/python-sdk@090443dfb58534baee734f54013ed6199e7d8322 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/pictomancer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@090443dfb58534baee734f54013ed6199e7d8322 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pictomancer-0.2.0-py3-none-any.whl.
File metadata
- Download URL: pictomancer-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
20f974d40a7b9e8fc1bd3fb53a024535637589a8f599689ec99d44bab81cac08
|
|
| MD5 |
475ec832f19d93dff7a4499e0bc8808f
|
|
| BLAKE2b-256 |
3db56094b388434e8637a182cb5f3eda80b631f849efa53d6cdbb6a2688bc08d
|
Provenance
The following attestation bundles were made for pictomancer-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on pictomancer/python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pictomancer-0.2.0-py3-none-any.whl -
Subject digest:
20f974d40a7b9e8fc1bd3fb53a024535637589a8f599689ec99d44bab81cac08 - Sigstore transparency entry: 2201666265
- Sigstore integration time:
-
Permalink:
pictomancer/python-sdk@090443dfb58534baee734f54013ed6199e7d8322 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/pictomancer
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@090443dfb58534baee734f54013ed6199e7d8322 -
Trigger Event:
push
-
Statement type: