Skip to main content

Smart shrinking of the size and color palette of images

Project description

NoteShrinker
==========

This Repo packages up the work from [Mark Zucker](https://github.com/mzucker/noteshrink) into a python module and cli script

Convert scans of handwritten notes to beautiful, compact *PDFs* [see full writeup](https://mzucker.github.io/2016/09/20/noteshrink.html)

Note this package does not convert to PDF as the original module relies on ImageMagick, this is very easy to implement yourself.


Examples
------------
These examples use the default settings in the Python module.

Original | NoteShrunk
:-------------------------:|:-------------------------:
**Size: 1.4MB**![Original example 1](Examples/Input/us_tax_form_1937.jpg?raw=true "Original US Tax return form from 1937") | **Size: 516KB**![NoteShunk example 1](Examples/Output/us_tax_form_1937.png?raw=true "NoteShrunk US Tax return form from 1937")
**Size: 73KB**![Original example 2](Examples/Input/winston_churchhill_letter.jpg?raw=true "Original letter from Winston Churchhill") | **Size: 51KB**![NoteShunk example 2](Examples/Output/winston_churchhill_letter.png?raw=true "NoteShrunk letter from Winston Churchhill")
**Size: 132KB**![Original example 3](Examples/Input/Restraint_of_domestic_animals.jpg?raw=true "Original page from 'Restraint of domestic animals'")| **Size: 109KB**![NoteShunk example 3](Examples/Output/Restraint_of_domestic_animals.png?raw=true "NoteShrunk page from 'Restraint of domestic animals'")


Requirements
------------

- Python 2 or 3
- NumPy 1.10 or later
- SciPy
- Image module from PIL or Pillow


Installation
-----

**Ensure you have Numpy, SciPy and PIL installed:**

```python
pip install numpy scipy pillow
```

```python
pip install NoteShrinker
```

Usage
-----

**Docker**
```bash
docker run -v $PWD/Examples/Input:/imgs challisa/note-shrinker /imgs/us_tax_form_1937.jpg -w
```

**Command line**
```bash
note-shrinker IMAGE1 [IMAGE2 ...]
```

**Integrating into your Python scripts**

```python
from NoteShrinker import NoteShinker

# Create a NoteShrink object full of images, either an array of filepaths, PIL images or numpy arrays
ns = NoteShrinker(['test.png'], **args)

# Shrink the images by calling the shrink method, this returns an array of PIL images encoded as RGB
shrunk = ns.shrink()

# Carry on with your image processing...
for img in shrunk:
img.save('example.png')
```


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

NoteShrinker-0.1.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

NoteShrinker-0.1.1-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file NoteShrinker-0.1.1.tar.gz.

File metadata

  • Download URL: NoteShrinker-0.1.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for NoteShrinker-0.1.1.tar.gz
Algorithm Hash digest
SHA256 1dee78222d5b4987dce38a6781ba47a5cecb479c8f75f604e56cc6425e968ff3
MD5 e73b4b6896ff0b307332717ef2694ae0
BLAKE2b-256 b430e1bd2a731eb3c2533ab299b333af2b30ce73aa7f322833776b3e7d3dd1f0

See more details on using hashes here.

File details

Details for the file NoteShrinker-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: NoteShrinker-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.19.1 setuptools/20.7.0 requests-toolbelt/0.8.0 tqdm/4.24.0 CPython/3.6.5

File hashes

Hashes for NoteShrinker-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 699e13b37121eb7ea879d85244b3f29ffd9cad514f428c07effa8d070760dbce
MD5 965437a3571b8f61eaf8bfd289ea789c
BLAKE2b-256 e75febf167bbbf1062e82c428d0fa48a66bed4f5ff7c99c86496e3d3369175ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page