tourze / risky-image-detect-bundle
提供风险图片检测和识别功能的 Symfony Bundle
Installs: 147
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/risky-image-detect-bundle
Requires
- php: ^8.1
- psr/log: ^3|^2|^1
- symfony/config: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/event-dispatcher: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-kernel: ^6.4
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-11-01 19:23:44 UTC
README
A Symfony Bundle for detecting risky image content, providing a secure image validation service.
Features
- Simple and extensible interface for risky image detection
- Default implementation ready to use out of the box
- Easy to customize with your own detection logic
- Fully compatible with Symfony 6.4+ and PHP 8.1+
- Comprehensive test coverage
Installation
Install this package using Composer:
composer require tourze/risky-image-detect-bundle
Configuration
Enable this bundle in your Symfony project:
// config/bundles.php return [ // ... Tourze\RiskyImageDetectBundle\RiskyImageDetectBundle::class => ['all' => true], ];
Quick Start
This bundle provides a RiskyImageDetector interface and its default implementation DefaultRiskyImageDetector for detecting risky image content.
<?php use Tourze\RiskyImageDetectBundle\Service\RiskyImageDetector; class ImageProcessingService { public function __construct( private readonly RiskyImageDetector $riskyImageDetector ) { } public function processImage(string $imageData): void { if ($this->riskyImageDetector->isRiskyImage($imageData)) { // Handle risky image... throw new \Exception('Risky image detected'); } else { // Process normal image... $this->processNormalImage($imageData); } } private function processNormalImage(string $imageData): void { // Your image processing logic here } }
Customization
You can create your own RiskyImageDetector implementation and set it as the default using Symfony's service configuration:
// src/Service/CustomRiskyImageDetector.php namespace App\Service; use Symfony\Component\DependencyInjection\Attribute\AsAlias; use Tourze\RiskyImageDetectBundle\Service\RiskyImageDetector; #[AsAlias(RiskyImageDetector::class)] class CustomRiskyImageDetector implements RiskyImageDetector { public function isRiskyImage(string $image): bool { // Your custom implementation... // For example, integrate with external API or use ML models return $this->checkWithExternalService($image); } private function checkWithExternalService(string $image): bool { // Implementation details... return false; } }
Development
Run tests:
./vendor/bin/phpunit packages/risky-image-detect-bundle/tests
Run static analysis:
php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/risky-image-detect-bundle
License
This package is released under the MIT License. See LICENSE file for details.