Extract individual post-it notes from scanned images. Detects colored post-its on a white background, straightens them, auto-orients the text, and saves each as a separate file.
Extracted:
- Detection — Thresholds the HSV saturation channel to separate colored post-its from the white scanner background
- Straightening — Uses
minAreaRectto find the precise bounding rectangle, then applies a perspective transform to de-skew - Auto-orientation — Runs Tesseract OCR at 0/90/180/270 rotations and picks the orientation with the most recognized text
- Python 3
- OpenCV (
pip install opencv-python) - NumPy (
pip install numpy) - Tesseract OCR (for auto-orientation)
On macOS:
brew install tesseract
pip install opencv-python numpypython3 extract_postits.py image.jpg [image2.jpg ...]Each detected post-it is saved as <basename>_postit_<n>.jpg alongside the input file.
python3 extract_postits.py --debug image.jpgGenerates additional debug images:
*_debug_mask.jpg— the saturation-based detection mask*_debug_outline.jpg— detected bounding rectangles overlaid on the original
You can set up a Finder Quick Action so you can right-click any image and extract post-its directly.
- Open Automator and create a new Quick Action
- Set "Workflow receives current" to
image filesinFinder.app - Add a Run Shell Script action
- Set Shell to
/bin/zshand Pass input toas arguments - Paste the following script (update the paths to match your setup):
export PATH="/usr/local/bin:/opt/homebrew/bin:$PATH"
PYTHON="/path/to/python3"
SCRIPT="/path/to/extract_postits.py"
for f in "$@"; do
"$PYTHON" "$SCRIPT" "$f"
done
osascript -e 'display notification "Post-its extracted!" with title "Post-it Extractor"'- Save as
Extract Post-its
The action will appear when you right-click image files in Finder under Quick Actions. Extracted post-its are saved next to the original file.
- Works best with colored post-its (yellow, pink, green, blue) on a white/light background
- Post-its can be at any angle
- Multiple post-its per scan are supported
- Auto-orientation works best when the post-it has legible handwriting or printed text
MIT



