Crates.io | image-anonymizer |
lib.rs | image-anonymizer |
version | |
source | src |
created_at | 2025-03-01 23:26:43.014723+00 |
updated_at | 2025-03-03 21:20:33.926175+00 |
description | A command-line tool to detect and mask sensitive content in images |
homepage | |
repository | https://github.com/katsuhirohonda/image-anonymizer |
max_upload_size | |
id | 1574089 |
Cargo.toml error: | TOML parse error at line 18, column 1 | 18 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
A command-line tool to detect and mask sensitive content in images.
cargo install image-anonymizer
The application requires API keys to access Google Cloud Platform services. Create a .env
file in the root directory based on the .env.template
file:
# You need to set these environment variables
# GCP API Key for Google Cloud Platform need to access "Gemini for Google Cloud API", "Generative Language API" and "Cloud Vision API"
GCP_API_KEY=
GEMINI_MODEL=gemini-2.0-flash-lite
Fill in your GCP API key to enable text and face detection capabilities.
image-anonymizer [OPTIONS] <INPUT_FILE>
Options:
-o, --output-dir <DIR> Output directory for processed images [default: ./output]
-m, --mask-texts <TEXTS> Additional texts to mask, comma separated
-f, --mask-faces Enable face detection and mosaic masking
-h, --help Print help
-V, --version Print version
The tool can detect and mask sensitive text such as email addresses, API keys, and other personal information.
Example 1
Example 2
The tool can automatically detect faces in images and apply a mosaic effect to protect privacy.
Before | After |
---|---|
![]() |
![]() |
# Process a single image
image-anonymizer screenshot.png
# Process an image and specify output directory
image-anonymizer --output-dir ./masked_images screenshot.png
# Process an image and mask additional text
image-anonymizer --mask-texts "secret,confidential" screenshot.png
# Process an image and apply mosaic to faces
image-anonymizer --mask-faces screenshot.png
# Process an image, mask both faces and specific text
image-anonymizer --mask-faces --mask-texts "confidential" screenshot.png
# Run all tests excluding integration tests that require API keys
cargo test
# Run all tests including integration tests
# (requires valid API keys in .env)
cargo test -- --include-ignored
# Run specific test
cargo test test_mask_text_with_annotations
# Run tests with logging
RUST_LOG=debug cargo test
Note: Some tests require a valid GCP API key to be set in the environment or in a .env
file. Tests that make API calls are marked as #[ignore]
and can be run with the --include-ignored
flag.
This project is licensed under the MIT License - see the LICENSE file for details.