Last active
March 10, 2026 16:59
-
-
Save ErichDonGubler/0377570cef83bde5c655339380765b08 to your computer and use it in GitHub Desktop.
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
| # Take all provided images and put them into PDF using Python's Pillow library. | |
| # | |
| # Uses `uvx`. If you don't have it, you will need to install it. | |
| # | |
| # # Examples | |
| @example "turn pages from scans into a PDF" { ls ~/Downloads/scanned_images | get name | images-to-pdf } | |
| export def "main" [ | |
| --to: oneof<path, nothing>, | |
| # The output path of the PDF. | |
| ]: list<path> -> nothing { | |
| if (which uvx | is-empty) { | |
| error make --unspanned { | |
| msg: "`uvx` isn't on `PATH`; do you need to install it?" | |
| } | |
| } | |
| if $to == null { | |
| error make --unspanned { | |
| msg: "`--to` can't be `null`, please specify" | |
| } | |
| } | |
| let to = $to | to nuon | |
| let paths_list_nuon = $in | to nuon | |
| let python_script = [ | |
| 'from PIL import Image' | |
| $"images = [Image.open\(f\) for f in ($paths_list_nuon)]" | |
| $"images[0].save\(($to), save_all=True, append_images=images[1:]\)" | |
| ] | str join '; ' | |
| uvx --with pillow python -c $python_script | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment