Python script to make documents look like they were scanned.
Project description
look-like-scanned
-
Python script to make documents look like they were scanned.
-
It converts every page of a given PDF file into an image-based page and applies random askew and brightness (very mild) effects to simulate the appearance of scanned documents.
-
The resulting pages are then combined back into an Output PDF file.
-
There are options to combine / convert image files into PDF as well.
-
Output PDF files are saved in the same input folder with a suffix "filename_output.pdf"
Installation
git clone https://github.com/navchandar/look-like-scanned.git
pip install poetry
poetry install
pip install .
Usage
This package uses PIL and pypdfium2 to convert and manipulate image and pdf objects.
This is extended to provide a command-line interface (CLI) for easy usage.
# Convert all pdf files in folder to scanned pdf
scanner -i .\tests
scanner -i .\tests -f "pdf"
# Convert all pdf files in folder to scanned without askew
scanner -i .\tests -a no
# Convert specific pdf file in folder to scanned pdf
scanner -i .\tests -f "test.pdf"
# Convert all jpg, jpeg, png, webp files in folder to one pdf file
scanner -i .\tests -f "image"
# Convert all png files in folder to pdf with 100% quality to one pdf file
scanner -i .\tests -f "png" -q 100
# Convert specific jpg file in folder to pdf with 75% quality to one pdf file
scanner -i .\tests -f "JPG_Test.jpg" -q 75
# Convert all PDF files including sub folders
scanner -i .\tests -f "pdf" -r yes
# Convert all Images including sub folders into one PDF
scanner -i .\tests -f "image" -r yes
Arguments
These are the command-line arguments accepted:
-
-i, --input_folder
: Specifies the input folder to read files from and convert. The default value is the current directory.- Example:
-i /path/to/files
or-i C:\files\documents
- Example:
-
-f, --file_type_or_name
: Specifies the file types to process or the file name to convert. The default value is "pdf" to convert all pdf files in the given input folder.- Example:
-f pdf
or-f image.jpg
or-f image
- Example:
-
-q, --file_quality
: Specifies the quality of the converted output files. The value must be between 50 and 100. The default value is 95.- Example:
-q 90
- Example:
-
-a, --askew
: Controls whether to make the output documents slightly askew or slightly tilted. Accepted values are "yes" or "no". The default value is "yes".- Example:
-a yes
or--askew no
- Example:
-
-r, --recurse
: Allows scripts to find all matching files including subdirectories. Accepted values are "yes" or "no". The default value is "yes".- Example:
-r yes
or--recurse no
- Example:
❗❗ Note: ❗❗
-
The supported file types are: ".jpg", ".png", ".jpeg", ".webp", ".pdf".
-
The output PDF file size will be bigger compared to the input because the files are stored in image format.
-
Bookmarks / Links / Metadata will be removed when saving the output file.
-
Password protected PDF files are not yet supported.
License
Support This Project
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file look_like_scanned-0.2.0.tar.gz
.
File metadata
- Download URL: look_like_scanned-0.2.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0df7f8517c31fcfad54f453918bb31df57bc52380932ebdb9f9b785c9e838645 |
|
MD5 | 44a4651812f4fdbee7beed0908e73d95 |
|
BLAKE2b-256 | fa64d20e2283c83cce1f2270a38149153be400cb75a0b5840e95f3856f679693 |
File details
Details for the file look_like_scanned-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: look_like_scanned-0.2.0-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 498d8066fec36f255b963cc6a7482a67d491cb01264bdeef203511d4d6337133 |
|
MD5 | f7c82afe096e6fb615773684ccc2c6f7 |
|
BLAKE2b-256 | be32b9c407acf1491df6e58bc77e13c2513513e6a7a9bf9d512c7a48bb15ecea |