NoteShrinker

Smart shrinking of the size and color palette of images


Keywords
noteshrink, compression, forms, image, image-processing, ocr
License
MIT
Install
pip install NoteShrinker==0.2.0

Documentation

NoteShrinker

GitHub stars Docker build Travis build Package version License

This Repo packages up the work from Mark Zucker into a python module and cli script

Convert scans of handwritten notes to beautiful, compact PDFs see full writeup

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.4MBOriginal example 1 Size: 516KBNoteShunk example 1
Size: 73KBOriginal example 2 Size: 51KBNoteShunk example 2
Size: 132KBOriginal example 3 Size: 109KBNoteShunk example 3

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:

pip install numpy scipy pillow
pip install NoteShrinker

Usage

Docker

docker run -v $PWD/Examples/Input:/imgs challisa/noteshrinker /imgs/us_tax_form_1937.jpg -w

Command line

    note-shrinker IMAGE1 [IMAGE2 ...]

Integrating into your Python scripts

from NoteShrinker import NoteShrinker

# 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')