Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

Entropy-based image border detection algorithm library

Project Description

Entropy-based image border detection algorithm: finds out if your image has borders or whitespaces around and helps you to trim border providing whitespace offsets for every side of a picture, supports animated GIFs.

Algorithm (simplified)

For each side of the image starting from top, rotating image counterclockwise to keep side of interest on top:

  • Get upper block 25% of image height
  • Get lower block with the same height as the upper one
  • Calculate entropy for both blocks and their difference
  • Make upper block 1px less
  • Repeat from p.2 until we hit image edge
  • Border is between blocks with entropy difference maximum


Python 3.5+


python-3.6 -m venv .env
source .env/bin/activate
pip install enimda


Find if image has borders:

from enimda import ENIMDA

# Load target image
em = ENIMDA(fp='test.jpg')

# Scan for borders with high precision
borders = em.scan(fast=False)

# Print found image borders (tuple): top, right, bottom, left


For demo please refer to ENIMDA Demo

Also it lives at Picture Instruments as ‘Remove borders’ instrument


Run tests: py.test

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

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

Filename, Size & Hash SHA256 Hash Help File Type Python Version Upload Date
(6.8 kB) Copy SHA256 Hash SHA256
Wheel 3.6 May 25, 2017
(4.2 kB) Copy SHA256 Hash SHA256
Source None May 25, 2017

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers