Extract an API to predict the DPI used by img2pdf (with Pillow) #200
Loading…
Reference in a new issue
No description provided.
Delete branch "mara0004/img2pdf:dpi_predictor"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When embedding img2pdf in a processing pipeline, it may be desired to predict the output size without actually converting the image, to defer any heavy processing to the export layer.
img2pdf applies some adjustments to the DPI provided by Pillow, so factor these out into a separate function that can be used by the embedder to calculate output size.
A possible issue I see with this is that it only covers the Pillow part, i.e. not the custom MIFF and JP2 parsers.
Pillow should be able to handle JP2 these days (at least current Linux wheels do), and I'm not too interested in MIFF, so this would already be helpful to me.
Yet, it might seem preferable to have a DPI function that could cover all code paths, but I'm not sure that's feasible, as the MIFF and JP2 DPI seem to be buried rather deeply in the control flow, or tied to other work.
And this would need a more complex API design than for just a Pillow image that can be seek()'ed by the caller...
This change looks okay. Did you run the testsuite for your pull requests?
Thanks. Yes, I did run the test suite.
The thing is, on my distro (Fedora 37), 10 tests are already failing on unaltered main.
This patch does not change the number of failing tests, but perhaps you had better confirm this did not break anything by running tests yourself, assuming there aren't any test suite issues on your end.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.