Repository navigation
Fix the PDF thumbnail example: convert page 1 straight to JPG - #61
Merged
Merged
Conversation
pdf -> extract is now the AI data-extraction converter: it returns JSON and has no PageRange, so the example's second step got a JSON file instead of page 1 and failed. One pdf -> jpg call with PageRange=1 now makes the thumbnail, in one conversion instead of two. ScaleImage and ScaleProportions are not pdf -> jpg parameters and the API ignored them, so the 300x300 request came back 300x388 for test.pdf. FitToSize keeps the thumbnail inside 300x300 (231x300). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 6, 2026
Merged
Merged
Merged
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the PDF thumbnail example update.
No open issues 🎉
What changed in this PR
Fixes the PDF thumbnail example by converting the first PDF page directly to JPG, avoiding the extraction converter’s JSON output.
Changes:
- Replaces the two-step conversion with one PDF-to-JPG call using
PageRange: 1. - Replaces unsupported scaling options with
FitToSizeto preserve aspect ratio within 300×300 pixels. - Updates the explanatory comment and removes the extraction documentation link.
| File | Description |
|---|---|
examples/create_pdf_thumbnail.py |
Converts page 1 directly to a size-constrained JPG thumbnail and updates the comments. |
Review effort: Balanced
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The example cut page 1 out of the PDF with the
extractconverter andPageRange1, then converted that page to JPG.pdf -> extractis now the AI data-extraction converter: it returns JSON and has noPageRangeparameter (spec), so the second step gets a JSON file instead of page 1.On
mainit fails:Change
pdf -> jpgcall withPageRange1 makes the thumbnail: one conversion instead of two.ScaleImageandScaleProportionsare dropped. They are notpdf -> jpgparameters (spec) and the API ignores them: with or without them,ImageHeight300 +ImageWidth300 returns a 300x388 image fortest.pdf(US Letter), byte for byte the same.FitToSizekeeps the thumbnail inside 300x300 with its aspect ratio: 231x300.Verification
Run from
examples/against the production API on 2026-11-06, Python 3.14.7, with the SDK installed from this branch ($TMPDIRis the local temp folder):test.jpgis 231x300 px, 8,858 bytes.Only the example changes, not the library, so there is no CHANGELOG entry.
The thumbnail examples of the other SDKs are fixed in ConvertAPI/convertapi-library-php#72, ConvertAPI/convertapi-library-ruby#42, ConvertAPI/convertapi-library-java#56, ConvertAPI/convertapi-library-dotnet#82, ConvertAPI/convertapi-library-node#123.
🤖 Generated with Claude Code