Skip to content

Feat/pdf dpi option - #91

Merged
kingrishabdugar merged 3 commits into
kingrishabdugar:mainfrom
AmariAugustin:feat/pdf-dpi-option
Oct 8, 2026
Merged

kingrishabdugar merged 3 commits into
kingrishabdugar:mainfrom
AmariAugustin:feat/pdf-dpi-option

Conversation

@AmariAugustin

Copy link
Copy Markdown
Contributor

What does this change?

PDF to JPG and PDF to PNG now have a Quality select: 72 DPI (small files for the web), 150 DPI (default, unchanged) and 300 DPI (print).

  • pdfToImages(file, format, dpi = 150) renders at dpi / 72
  • Select added in optionsHtml(), reusing ws.quality / ws.dpiStandard / ws.dpiHigh; one new string ws.dpiLow
  • LOCAL passes Number(o.dpi) || 150

Closes #6

Type of change

  • 🐛 Bug fix
  • 🧰 New tool or feature
  • 🌍 Translation
  • 📝 Docs
  • 🧹 Refactor / tooling

How did you test it?

On /pdf-to-jpg/ and /pdf-to-png/ with a one-page PDF: the select defaults to 150 DPI, and 72 / 150 / 300 give images 400 / 834 / 1667 px wide for a 400 pt page. The PDF → PNG browser test in tests/app.e2e.ts now checks these three sizes.

image

Note: on Windows, tests/app.e2e.ts and tests/mcp.test.ts fail before reaching any tool because fixture paths are built with URL.pathname (gives C:\C:\...). I ran the e2e test with fileURLToPath locally (not committed). Happy to open a separate PR for that if you'd like.

Checklist

  • Nothing leaves the visitor's device (no new network requests, CDNs or third-party scripts)
  • npm run check passes
  • npm run test:e2e passes
  • New user-facing text is added to src/i18n.ts (English) — translators will pick it up
  • New dependencies (if any) are permissively licensed and listed in THIRD_PARTY_NOTICES.md

pdfToImages() always rendered at 150 DPI. It now takes a dpi argument (150 by default, so callers are unchanged) and scales the page by dpi / 72, the number of PDF units per inch.

Refs kingrishabdugar#6
Adds a Quality select to PDF to JPG and PDF to PNG: low (72 DPI) for small web images, standard (150 DPI, still the default) and high (300 DPI) for print. It reuses the Redact PDF strings and adds one for 72 DPI; other languages fall back to English.

Refs kingrishabdugar#6
Extends the PDF to PNG browser test: a 400 pt wide page must come out 400, 834 and 1667 px wide at 72, 150 and 300 DPI, and the select must default to 150.

Refs kingrishabdugar#6
@kingrishabdugar
kingrishabdugar merged commit ba5de63 into kingrishabdugar:main Oct 8, 2026
2 checks passed

kingrishabdugar commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

Thank you so much, @AmariAugustin! This is a really clean PR: the change is small, the default stays at 150 DPI so nothing changes for existing users, and the test that checks the real image width at each DPI is exactly the kind of check I like to see. Merged 🎉

A few tiny notes for next time (nothing blocking, I'll handle them in a follow-up):

  • The 'pdf-to-jpg' line in src/app.ts has a few extra spaces of indentation, and there's a trailing space at the end of the new line in src/seo.ts.
  • New UI strings like ws.dpiLow also need an entry in each src/i18n/*.json file, otherwise those languages fall back to English. I'll add the translations for this one.

And yes, please do send the Windows test-path fix (URL.pathname) as a separate PR — that would be very welcome.

Which issue would you like to pick up next? Have a look at the open issues and tell me which one interests you, and I'll assign it to you. Thanks again for the great contribution!

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.

PDF → JPG / PNG: let users choose the resolution (DPI)

2 participants