Skip to main content

Official Python client for the image2ppt API — convert images and PDFs into editable PowerPoint (.pptx).

Project description

image2ppt — Python client

Official Python client for the image2ppt API. Turn a batch of images or PDF pages into one editable PowerPoint (.pptx).

Install

pip install image2ppt

Requires Python 3.9+. Depends on requests and Pillow (Pillow powers optional client-side image pre-compression — see below).

Get an API key

Sign in at image2ppt.com, open Developer / API from the account menu, and create a key (looks like i2p_live_xxxx). It's shown in full once — save it. API access is available to accounts with credits.

Server-side only. Keep your key on your backend. Never embed it in a browser, mobile app, or anything a user can inspect.

Quick start

One shot — submit, wait, download:

from image2ppt import Image2PPTClient

client = Image2PPTClient(api_key="i2p_live_your_key")

job = client.convert(
    ["slide1.png", "slide2.png", "report.pdf"],
    dest_path="out.pptx",
    locale="zh-CN",       # optional: "zh-CN" (default) or "en"
    aspect_ratio="16:9",  # optional: "auto" (default) / "16:9" / "4:3"
)
print("done — credits used:", job.credits_used, "refunded:", job.credits_refunded)

Step by step, if you want to control polling:

job = client.submit(["slide1.png"], aspect_ratio="4:3")
print("job:", job.job_id, "credits reserved:", job.credits_reserved)

job = client.wait(job.job_id, poll_interval=5, timeout=1800)
client.download(job.job_id, "out.pptx")

Check your balance:

info = client.account()
print(info["email"], "credits:", info["credits"])

How it works

  • Async. submit returns a job id immediately; conversion runs in the background. A single page typically takes ~2 minutes; 90% of jobs finish within 3.
  • One job = one PPTX. All files in a submission are merged into a single deck, in upload order.
  • Billed per page. 1 page = 1 credit, reserved at submit and settled on completion. If some pages fail but others succeed, the job still completeds with the good pages and the failed pages' credits are refunded (credits_refunded).
  • Limits. Each file ≤ 35MB; total ≤ 50 pages per job (images count as 1, PDFs as their page count).
  • Client-side pre-compression. Images are compressed to the server's spec before upload (≤2000px, ≤1MB, JPEG), so the server's own pass is a no-op and you send fewer bytes. PDFs are uploaded as-is and rendered server-side.

Rate limits

Per account (all keys share the budget): ≤ 10 concurrent jobs, ≤ 60 pages/minute submitted. Over the limit returns 429 with a Retry-After hint. wait() handles 429 backoff for you automatically. If you call submit() directly, catch RateLimitedError and honor retry_after:

import time
from image2ppt import RateLimitedError

while True:
    try:
        job = client.submit(paths)
        break
    except RateLimitedError as e:
        time.sleep(e.retry_after or 5)

Errors

Every exception subclasses Image2PPTError and carries status_code, code, and message. Branch on code, not message.

Exception HTTP code
AuthenticationError 401 / 403 INVALID_API_KEY, API_KEY_REQUIRED, ACCOUNT_DELETED
InvalidFileError 400 INVALID_FILE
TooManySlidesError 400 TOO_MANY_SLIDES
InsufficientCreditsError 402 INSUFFICIENT_CREDITS
RateLimitedError 429 RATE_LIMITED (has retry_after)
JobNotFoundError 404 JOB_NOT_FOUND
NotReadyError 409 NOT_READY
OutputExpiredError 410 OUTPUT_EXPIRED
JobFailedError job's error.code (raised by wait(); e.job is the snapshot)
Image2PPTTimeoutError — (wait() exceeded its timeout; job may still be running)
from image2ppt import Image2PPTError, JobFailedError

try:
    job = client.convert(paths, "out.pptx")
except JobFailedError as e:
    print("conversion failed:", e.code, e.message)
except Image2PPTError as e:
    print("request error:", e.status_code, e.code, e.message)

Full API reference

See ../docs/api.md for the complete HTTP contract (endpoints, fields, error codes).

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

image2ppt-0.1.0.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

image2ppt-0.1.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file image2ppt-0.1.0.tar.gz.

File metadata

  • Download URL: image2ppt-0.1.0.tar.gz
  • Upload date:
  • Size: 10.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for image2ppt-0.1.0.tar.gz
Algorithm Hash digest
SHA256 42c17b724137bd55c91657dd3189a45e1af3c34dfe5e303fef836ced42ac7d06
MD5 c225512fbfd096dd5aed86894a24ef19
BLAKE2b-256 f142f258ff40378c56c2436f6b5adf26884cedc1ade9a339787a8c766919198d

See more details on using hashes here.

File details

Details for the file image2ppt-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: image2ppt-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.1 {"installer":{"name":"uv","version":"0.11.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for image2ppt-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5ca7855e6d1e7b4bba1819c97911cab3ebf75ccb5f10ca9a3acbb3766ecb1482
MD5 afbdfc4d897025fa7cd8defb5dd4c5ef
BLAKE2b-256 784d90b115b1ab95108526b227c10e2538aa193a76061d022597434cbae688b3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page