Files
lua-scripts-w-api/contrib/darktable-api/bruno/images/Get Preview.bru
stephen schuresko bd40b4f850 Add darktable REST API implementation
- Introduced a new Lua-based REST API for darktable, allowing external applications to interact with the darktable library.
- Implemented core functionalities including image listing, retrieval, and preview serving.
- Added support for OAuth 2.0 authentication with token generation.
- Created a simple HTTP router to handle API requests.
- Included JSON encoding/decoding utilities for API responses.
- Developed a script to launch the API server alongside darktable, ensuring seamless integration.
- Added necessary configuration and setup for the API server, including CORS support and error handling.
2026-06-10 15:02:19 -04:00

68 lines
1.4 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
meta {
name: Get Preview
type: http
seq: 4
}
get {
url: {{baseUrl}}/api/v1/images/{{imageId}}/preview
body: none
auth: bearer
}
auth:bearer {
token: {{accessToken}}
}
params:query {
size: small
~size: medium
~size: large
~size: thumb
~size: xlarge
}
tests {
test("returns 200 or 404", function() {
expect([200, 404]).to.include(res.status);
});
test("if 200, content-type is image/jpeg or image/png", function() {
if (res.status === 200) {
expect(res.headers["content-type"]).to.match(/image\/(jpeg|png)/);
}
});
test("if 200, body is non-empty", function() {
if (res.status === 200) {
expect(res.body.length).to.be.above(0);
}
});
test("if 404, no_preview error returned", function() {
if (res.status === 404) {
expect(res.body.error).to.equal("no_preview");
}
});
}
docs {
## Get Preview
Returns a JPEG thumbnail from darktable's mipmap cache.
### Size options
| Value | Approx. long edge |
|---|---|
| `thumb` | ~135 px |
| `small` | ~270 px |
| `medium` | ~540 px (default) |
| `large` | ~1080 px |
| `xlarge` | ~2160 px |
| `0`–`5` | Raw mip level |
Only one `size` param is active at a time — uncomment the desired one above.
Falls back to lower mip levels automatically if the requested size isn't cached.
Returns 404 if no cached thumbnail exists at any level.
}