{"id":5258,"library":"imutils","title":"imutils: Image Processing Utility Functions","description":"imutils is a Python package providing a series of convenience functions to simplify basic image processing operations such as translation, rotation, resizing, skeletonization, displaying Matplotlib images, sorting contours, and detecting edges. It acts as a companion library to OpenCV, streamlining common tasks and reducing boilerplate code. The current version is 0.5.4, released on January 15, 2021. The library has a slow release cadence, with no new versions in over three years, suggesting it is in maintenance mode rather than active development.","status":"maintenance","version":"0.5.4","language":"en","source_language":"en","source_url":"https://github.com/jrosebr1/imutils","tags":["computer vision","image processing","opencv","utilities","helper functions"],"install":[{"cmd":"pip install imutils","lang":"bash","label":"Install imutils via pip"}],"dependencies":[{"reason":"Imutils heavily relies on OpenCV for all its image processing functionalities. This (or `opencv-contrib-python`) must be installed separately.","package":"opencv-python","optional":false},{"reason":"Used for numerical operations on image arrays, a core dependency for image manipulation in Python.","package":"numpy","optional":false},{"reason":"Often used for displaying images, especially in development and debugging contexts.","package":"matplotlib","optional":true}],"imports":[{"symbol":"imutils","correct":"import imutils"},{"symbol":"resize","correct":"from imutils import resize"},{"symbol":"rotate","correct":"from imutils import rotate"},{"symbol":"translate","correct":"from imutils import translate"},{"symbol":"VideoStream","correct":"from imutils.video import VideoStream"},{"symbol":"FPS","correct":"from imutils.video import FPS"},{"note":"Some older examples might show direct access, but it's typically found in `imutils.contours`.","wrong":"imutils.grab_contours()","symbol":"grab_contours","correct":"from imutils.contours import grab_contours"}],"quickstart":{"code":"import cv2\nimport imutils\nimport numpy as np\n\n# Simulate reading an image (replace with cv2.imread('path/to/image.jpg'))\n# For demonstration, create a dummy black image (BGR format)\nimage = np.zeros((300, 500, 3), dtype=\"uint8\")\ncv2.putText(image, \"Original Image\", (100, 150), cv2.FONT_HERSHEY_SIMPLEX, 1, (255, 255, 255), 2)\n\n# Use imutils.resize to resize the image while maintaining aspect ratio\nresized_image = imutils.resize(image, width=150)\n\n# Display original and resized images\ncv2.imshow(\"Original\", image)\ncv2.imshow(\"Resized (width=150)\", resized_image)\n\ncv2.waitKey(0)\ncv2.destroyAllWindows()","lang":"python","description":"This quickstart demonstrates how to use `imutils.resize` to scale an image while preserving its aspect ratio. It first creates a dummy image (you'd typically load one with `cv2.imread`) and then resizes it to a specified width. Both the original and resized images are displayed using OpenCV's `imshow` function."},"warnings":[{"fix":"Consider alternatives for specific functionalities or manually install dependencies if encountering build errors. Users have reported issues on GitHub related to `setuptools` not being available in the build environment.","message":"As of late 2024, `imutils` has faced installation issues (e.g., `error: metadata-generation-failed`) for some users due to its reliance on `distutils` and `setup.py`, which are deprecated in newer Python/pip environments. The project also appears to be unmaintained, with no recent updates or fixes to these issues.","severity":"breaking","affected_versions":"0.5.4 and potentially older versions with newer pip/Python environments"},{"fix":"Ensure `opencv-python` is installed: `pip install opencv-python`.","message":"Imutils is a wrapper around OpenCV; therefore, `opencv-python` (or `opencv-contrib-python`) is a crucial, unlisted peer dependency. Trying to use `imutils` without `opencv-python` installed will result in `ImportError: No module named 'cv2'`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure `numpy` is installed: `pip install numpy`.","message":"Similar to OpenCV, `imutils` operations often rely on NumPy arrays. Forgetting to install `numpy` can lead to `ModuleNotFoundError: No module named 'numpy'` or other runtime errors.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Convert the image from BGR to RGB before displaying with Matplotlib: `image_rgb = cv2.cvtColor(image_bgr, cv2.COLOR_BGR2RGB)`.","message":"When displaying images using Matplotlib, remember that OpenCV (and by extension, `imutils` results) stores images in BGR format, while Matplotlib expects RGB. Displaying a BGR image directly with Matplotlib will result in incorrect color representation (e.g., blue appears red and vice-versa).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-13T00:00:00.000Z","next_check":"2026-07-12T00:00:00.000Z"}