LLM fragment plugin to load a PDF as a sequence of images
Project description
llm-pdf-to-images
LLM fragment plugin to load a PDF as a sequence of images
Installation
Install this plugin in the same environment as LLM.
llm install llm-pdf-to-images
The llm-pdf-to-images plugin provides a fragment loader that converts each page of a PDF document into an image attachment.
You can use the pdf-to-images: fragment prefix to convert a PDF file into a series of image attachments which can be sent to a model.
Example usage:
llm -f pdf-to-images:path/to/document.pdf 'Summarize this document'
Fragment syntax
pdf-to-images:<path>?dpi=N&format=jpg|png&quality=Q
<path>: Path to the PDF file accessible to the environment where LLM runs.dpi=N: (optional) Dots per inch to use when rendering the PDF pages, which affects the resolution of the output images. Defaults to300if omitted.format=jpg|png: (optional) Image format to use for the output. Can be eitherjpg(default) orpng.quality=Q: (optional) JPEG quality factor between 1 and 100. Only applies when using JPG format. Defaults to30if omitted. Higher values produce better quality but larger file sizes.
More examples
Convert a PDF file to images with default settings (300 DPI, JPG format, quality 30):
llm -f pdf-to-images:document.pdf 'summarize this document'
Convert a PDF with higher resolution (600 DPI):
llm -f 'pdf-to-images:document.pdf?dpi=600' 'summarize'
Convert a PDF to PNG format:
llm -f 'pdf-to-images:document.pdf?format=png' 'describe all figures'
Convert a PDF with high-quality JPG images:
llm -f 'pdf-to-images:document.pdf?quality=90' 'extract all visible text'
Combine multiple parameters:
llm -f 'pdf-to-images:document.pdf?dpi=450&format=jpg&quality=75' 'OCR'
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd llm-pdf-to-images
python -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
python -m pip install -e '.[test]'
To run the tests:
python -m pytest
Project details
Release history Release notifications | RSS feed
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 llm_pdf_to_images-0.1.tar.gz.
File metadata
- Download URL: llm_pdf_to_images-0.1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
145e034289575cbce23a0332312635c3d8e33729fa5d6202420fad909dae2831
|
|
| MD5 |
a28853e78ae6f673eb510cd4d05bee1d
|
|
| BLAKE2b-256 |
1d2bea2c080e93e0a9e5d1d3450cdb34d2949e918d038e47233293a601e7d1d7
|
Provenance
The following attestation bundles were made for llm_pdf_to_images-0.1.tar.gz:
Publisher:
publish.yml on simonw/llm-pdf-to-images
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_pdf_to_images-0.1.tar.gz -
Subject digest:
145e034289575cbce23a0332312635c3d8e33729fa5d6202420fad909dae2831 - Sigstore transparency entry: 214874658
- Sigstore integration time:
-
Permalink:
simonw/llm-pdf-to-images@0ce38f1e0e5effc1ecff0aafd009417d7d78a745 -
Branch / Tag:
refs/tags/0.1 - Owner: https://github.com/simonw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0ce38f1e0e5effc1ecff0aafd009417d7d78a745 -
Trigger Event:
release
-
Statement type:
File details
Details for the file llm_pdf_to_images-0.1-py3-none-any.whl.
File metadata
- Download URL: llm_pdf_to_images-0.1-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0e477b6f6eade17c79b613d234faf3681fd1864942eb3062fec870609a93cc72
|
|
| MD5 |
794844b54aaf32007db3a3fcb57f9d9e
|
|
| BLAKE2b-256 |
6dd06f5fe2da16461bebbe1f2a43a44cedcccab0c535daaa5f5e77570fcc831e
|
Provenance
The following attestation bundles were made for llm_pdf_to_images-0.1-py3-none-any.whl:
Publisher:
publish.yml on simonw/llm-pdf-to-images
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_pdf_to_images-0.1-py3-none-any.whl -
Subject digest:
0e477b6f6eade17c79b613d234faf3681fd1864942eb3062fec870609a93cc72 - Sigstore transparency entry: 214874660
- Sigstore integration time:
-
Permalink:
simonw/llm-pdf-to-images@0ce38f1e0e5effc1ecff0aafd009417d7d78a745 -
Branch / Tag:
refs/tags/0.1 - Owner: https://github.com/simonw
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@0ce38f1e0e5effc1ecff0aafd009417d7d78a745 -
Trigger Event:
release
-
Statement type: