Repository navigation
README pdf-to-jpg snippet without ScaleImage/ScaleProportions - #30
Merged
Merged
Conversation
pdf-to-jpg has no ScaleImage or ScaleProportions parameters, and the API ignores unknown parameters silently. With both ImageWidth and ImageHeight and no FitToSize, the width wins and the height grows, so the snippet turned a US Letter page into a 300x388 JPG. FitToSize 'true' keeps the image inside 300x300 (231x300 on production, 2026-11-09). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the README-only update to the PDF-to-JPG sizing example.
No open issues 🎉
What changed in this PR
Corrects the README’s PDF-to-JPG example to use supported conversion parameters and preserve aspect ratio within a 300×300 bounding box. No library behavior changes.
Changes:
- Removes unsupported
ScaleImageandScaleProportionsparameters. - Adds
FitToSizewith the string value'true', retaining both image dimensions.
| File | Description |
|---|---|
| README.md | Updates the PDF-to-JPG sizing example to use FitToSize. |
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 README "Additional conversion parameters" snippet passed
ScaleImageandScaleProportionstopdf -> jpg. Neither is a pdf-to-jpg parameter (spec), and the API ignores them silently, so readers copy two parameters that do nothing. They exist only on jpg-to-jpg (spec).The snippet also sets both
ImageHeightandImageWidthto 300. WithoutFitToSize, pdf-to-jpg applies the width and lets the height grow, so a US Letter page comes back 300x388, not inside 300x300. Measured on production on 2026-11-06: the old parameters gave a 300x388 JPG, byte-identical to the same request withoutScaleImageandScaleProportions.Change
The snippet drops
ScaleImageandScaleProportionsand addsparams.add('FitToSize', 'true')afterImageWidth, so page 1 becomes a JPG that fits inside 300x300 and keeps the page's aspect ratio.params.addtakes string values, soFitToSizeis the string'true', asScaleImagewas. Nothing else in the README changes.Verification
One conversion on the production API on 2026-11-09: a multipart POST to
https://v2.convertapi.com/convert/pdf/to/jpgwith the snippet's parameters (ImageHeight300,ImageWidth300,FitToSizetrue) plusPageRange1, ontest.pdffrom the SDK examples (6 US Letter pages; the same file asassets/test.pdfin the Go SDK):test.jpgis 231x300 px, 8,858 bytes (sips -g pixelWidth -g pixelHeight), byte-identical to the JPGs the fixed Java and Go README snippets produce.PageRange1 only kept the check to one page: the snippet converts every page, andresult.files[0]is page 1.The live spec lists
ImageWidth,ImageHeight,PageRangeandFitToSize("scale the output image to fit within both ImageWidth and ImageHeight while maintaining the aspect ratio"; it needs both sizes), and noScaleImageorScaleProportions.Only the README changes, not the library's behaviour, so there is no CHANGELOG entry (RELEASING.md asks for one in pull requests that change behaviour).
The same README fix for Java is in ConvertAPI/convertapi-library-java#57, for Go in ConvertAPI/convertapi-library-go#21 and for .NET in ConvertAPI/convertapi-library-dotnet#83.
🤖 Generated with Claude Code