Download the PHP package tourze/blind-watermark without Composer
On this page you can find all versions of the php package tourze/blind-watermark. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package blind-watermark
Blind Watermark
中文
[]
(https://packagist.org/packages/tourze/blind-watermark)
[
]
(https://packagist.org/packages/tourze/blind-watermark)
[]
(https://packagist.org/packages/tourze/blind-watermark)
[
]
(https://packagist.org/packages/tourze/blind-watermark)
[]
(https://github.com/tourze/monorepo/actions)
[
]
(https://codecov.io/gh/tourze/monorepo)
A PHP implementation of blind watermarking technology that allows embedding invisible text watermarks into images using DCT (Discrete Cosine Transform).
Table of Contents
- Requirements
- Features
- Installation
- Quick Start
- Advanced Usage
- Command Line Usage
- Configuration Parameters
- Anti-Attack Features
- Exception Handling
- Technical Details
- Limitations
- Performance Considerations
- Security
- Contributing
- Changelog
- License
Requirements
- PHP 8.1 or higher
- GD extension
Features
- Invisible Watermarks: Embeds text watermarks that are imperceptible to human eyes
- Blind Extraction: Extract watermarks without requiring the original image
- DCT-based Technology: Uses frequency domain embedding for robust watermark placement
- Anti-attack Features:
- Symmetric embedding for flip resistance
- Multi-point embedding for enhanced robustness
- Geometric transformation correction
- Image Format Support: Supports JPEG and PNG formats
- Simple API: Easy-to-use interface for watermark embedding and extraction
Installation
Install via Composer:
Quick Start
Basic Usage
Embed Watermark
Extract Watermark
Advanced Usage
Advanced Configuration
Step-by-Step API
Command Line Usage
The package includes command-line scripts for easy watermark operations:
Embed watermark
Extract watermark
Configuration Parameters
| Parameter | Description | Default | Range |
|---|---|---|---|
alpha |
Watermark strength coefficient | 36.0 | 0.1 - 100.0 |
blockSize |
DCT block size | 8 | 4, 8, 16 |
position |
Embedding position in DCT matrix | [3, 4] | [0-7, 0-7] |
Anti-Attack Features
Symmetric Embedding
Protects against horizontal and vertical flipping by embedding watermark information symmetrically.
Multi-Point Embedding
Enhances robustness by embedding the same watermark bit at multiple positions.
Geometric Correction
Automatically detects and corrects geometric transformations before extraction.
Exception Handling
All errors are thrown as BlindWatermarkException:
Technical Details
The library implements blind watermarking using DCT (Discrete Cosine Transform):
-
Embedding Process:
- Decomposes the image into RGB channels
- Applies 8x8 block DCT transformation to the blue channel
- Embeds watermark bits in mid-frequency DCT coefficients
- Reconstructs the image using inverse DCT
- Extraction Process:
- Performs the same DCT transformation on the watermarked image
- Extracts embedded bits from the designated DCT coefficients
- Reconstructs the original text from the binary data
Limitations
- Text watermarks only (image watermarks not supported)
- Watermark capacity depends on image size
- Rotation support limited to 90-degree increments
- Requires GD extension (ImageMagick not supported)
Performance Considerations
- Larger
blockSizevalues reduce processing time but decrease watermark capacity - Higher
alphavalues increase watermark robustness but may affect image quality - Enabling anti-attack features increases processing time
Security
Security Considerations
- Watermark Detection: While watermarks are invisible to human eyes, they can potentially be detected by specialized analysis tools
- Text Limitations: Avoid embedding sensitive information as the extraction algorithm may be reverse-engineered
- File Integrity: Always verify image integrity before watermark extraction
- Parameter Protection: Keep watermark parameters (alpha, position) confidential for enhanced security
Best Practices
- Use strong, unique parameters for each watermarking session
- Implement additional encryption for sensitive watermark content
- Regularly test watermark robustness against common image processing operations
- Monitor for potential watermark removal attempts
Contributing
We welcome contributions! Please follow these guidelines:
Reporting Issues
- Use the GitHub issue tracker to report bugs
- Provide clear reproduction steps
- Include PHP version and system information
- Attach sample images if applicable
Submitting Pull Requests
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests:
./vendor/bin/phpunit packages/blind-watermark/tests - Run static analysis:
php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/blind-watermark - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Code Style
- Follow PSR-12 coding standards
- Use PHP 8.1+ features and type declarations
- Add PHPDoc comments for public methods
- Write meaningful variable and method names
Testing Requirements
- Write tests for new features
- Ensure all tests pass
- Maintain or improve code coverage
- Test edge cases and error conditions
Changelog
[Unreleased]
- Initial release
- Basic watermark embedding and extraction
- DCT-based implementation
- Anti-attack features (flip, rotation resistance)
- Command line interface
- Comprehensive test suite
License
This package is open-sourced software licensed under the MIT license.