Skip to content

README pdf-to-jpg snippet without ScaleImage/ScaleProportions - #30

Merged
tomasr78 merged 1 commit into
mainfrom
readme-pdf-to-jpg-params
Nov 9, 2026
Merged

tomasr78 merged 1 commit into
mainfrom
readme-pdf-to-jpg-params

Conversation

@tomasr78

@tomasr78 tomasr78 commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Problem

The README "Additional conversion parameters" snippet passed ScaleImage and ScaleProportions to pdf -> 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 ImageHeight and ImageWidth to 300. Without FitToSize, 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 without ScaleImage and ScaleProportions.

Change

The snippet drops ScaleImage and ScaleProportions and adds params.add('FitToSize', 'true') after ImageWidth, so page 1 becomes a JPG that fits inside 300x300 and keeps the page's aspect ratio. params.add takes string values, so FitToSize is the string 'true', as ScaleImage was. 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/jpg with the snippet's parameters (ImageHeight 300, ImageWidth 300, FitToSize true) plus PageRange 1, on test.pdf from the SDK examples (6 US Letter pages; the same file as assets/test.pdf in the Go SDK):

HTTP 200
{"ConversionCost": 1, "Files": [{"FileName": "test.jpg", "FileExt": "jpg", "FileSize": 8858}]}

test.jpg is 231x300 px, 8,858 bytes (sips -g pixelWidth -g pixelHeight), byte-identical to the JPGs the fixed Java and Go README snippets produce. PageRange 1 only kept the check to one page: the snippet converts every page, and result.files[0] is page 1.

The live spec lists ImageWidth, ImageHeight, PageRange and FitToSize ("scale the output image to fit within both ImageWidth and ImageHeight while maintaining the aspect ratio"; it needs both sizes), and no ScaleImage or ScaleProportions.

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

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>
Copilot AI balanced review requested due to automatic review settings November 9, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 ScaleImage and ScaleProportions parameters.
  • Adds FitToSize with 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

@tomasr78
tomasr78 merged commit df2759a into main Nov 9, 2026
7 of 9 checks passed
@tomasr78
tomasr78 deleted the readme-pdf-to-jpg-params branch November 9, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants