Presidio image redactor package
Project description
Presidio Image Redactor
Please notice, this package is still in alpha and not production ready.
Description
The Presidio Image Redactor is a Python based module for detecting and redacting PII text entities in images.
Deploy Presidio image redactor to Azure
Use the following button to deploy presidio image redactor to your Azure subscription.
Installation
Pre-requisites:
-
Install Tesseract OCR by following the instructions on how to install it for your operating system.
For now, image redactor only supports version 4.0.0
As package:
To get started with Presidio-image-redactor, run the following:
pip install presidio-image-redactor
Once Installed, run the following command to download the default spacy model needed for Presidio Analyzer:
python -m spacy download en_core_web_lg
Getting started
The engine will receive 2 parameters:
- Image to redact.
- Color fill to redact with, by default color fill will be black. Can either be an int or tuple (0,0,0)
from PIL import Image
from presidio_image_redactor import ImageRedactorEngine
# Get the image to redact using PIL lib (pillow)
image = Image.open("presidio-image-redactor/tests/integration/resources/ocr_test.png")
# Initialize the engine
engine = ImageRedactorEngine()
# Redact the image with pink color
redacted_image = engine.redact(image, (255, 192, 203))
# save the redacted image
redacted_image.save("new_image.png")
# uncomment to open the image for viewing
# redacted_image.show()
As docker service:
In folder presidio/presidio-image-redactor run:
docker-compose up -d
HTTP API
redact
Receives an image and color fill (optional, default is black). Redact the image PII text and returns a new redacted image.
POST /redact
Payload:
Sent as multipart-form. Contains image file and data of the required color fill.
{
"data": "{'color_fill':'0,0,0'}"
}
Result:
200 OK
curl example:
# use ocr_test.png as the image to redact, and 255 as the color fill.
# out.png is the new redacted image received from the server.
curl -XPOST "http://localhost:3000/redact" -H "content-type: multipart/form-data" -F "image=@ocr_test.png" -F "data=\"{'color_fill':'255'}\"" > out.png
Python script example can be found under: /presidio/e2e-tests/tests/test_image_redactor.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
File details
Details for the file presidio_image_redactor-0.0.42-py3-none-any.whl
.
File metadata
- Download URL: presidio_image_redactor-0.0.42-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b3b4bdb5a5e6e13b16127b9617278e3e66d98648cb67cdfd0ee34138a2570ca6 |
|
MD5 | 30f89ad14dae2b4493dc608c320f994f |
|
BLAKE2b-256 | 3c682cf794e2370a48f88564d797f6fb2c5692fe30bc9e9bdcf0ca965a4dd8e9 |