Added downscaling to pdfToImage-Converter to avoid too big images - #41
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the client-side PDF-to-image conversion utility to avoid generating overly large thumbnail images by iteratively downscaling and lowering output quality, and extends the blueprint setup script to include an additional template.
Changes:
- Add iterative scale/quality downscaling with a max output size threshold for
convertPdfToImageClient. - Switch PDF conversion output to JPEG and introduce a reusable
canvasToBlobhelper. - Add
hierarchical-structures-template.jsonto the blueprint setup list for VEC.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/lib/util/pdfToImage.ts | Adds max-size-aware downscaling logic and changes output to JPEG with a helper for blob creation. |
| scripts/setup-blueprints.js | Includes an additional template in the VEC blueprint generation list. |
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.
This pull request introduces improvements to the PDF-to-image conversion utility and updates blueprint template setup. The most significant change is the enhancement of the
convertPdfToImageClientfunction to automatically adjust image quality and scale to ensure the output file stays within a specified size limit. Additionally, a new blueprint template is added for hierarchical structures.PDF-to-image conversion improvements:
convertPdfToImageClientinpdfToImage.tsto automatically scale down and adjust image quality so the resulting image file does not exceed a specified maximum size (default 5MB). The function now tries multiple scales and JPEG qualities, falling back to the lowest quality if needed. The output file is always a JPEG. [1] [2] [3] [4]canvasToBlobfor flexible conversion of canvas to a blob with specified MIME type and quality.Blueprint template setup:
hierarchical-structures-template.jsonto the list of blueprint templates insetup-blueprints.js.