metastrip / image
A lightweight PHP library for efficiently removing EXIF, IPTC, and other metadata from images while preserving quality. Supports JPEG, PNG, and GIF formats.
Requires
- php: >=8.0
- ext-gd: *
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2024-11-21 12:39:56 UTC
README
A lightweight PHP library for efficiently removing EXIF, IPTC, and other metadata from images while preserving quality. Supports JPEG, PNG, and GIF formats.
Features
- Efficient metadata removal with zero quality loss
- Supports multiple image formats and metadata types:
- JPEG: EXIF and IPTC markers
- PNG: tEXt, iTXt, and zTXt chunks
- GIF: XMP and Application Extension blocks
- Privacy-focused: removes sensitive information
- Zero external dependencies (PHP GD only)
- Clean, object-oriented architecture
- Comprehensive test coverage
- PSR-12 compliant
Requirements
- PHP 8.0 or higher
- GD extension
Installation
Install via Composer:
composer require metastrip/image
Usage
Basic usage:
use MetaStrip\Image\ImageProcessorFactory; // Create processor instance $processor = ImageProcessorFactory::create(); // Strip metadata from an image $processor->stripExifData('/path/to/image.jpg');
Advanced usage with specific handlers:
use MetaStrip\Image\ImageProcessor; use MetaStrip\Image\ImageHandler\JpegHandler; use MetaStrip\Image\ImageHandler\PngHandler; use MetaStrip\Image\ImageHandler\GifHandler; // Create processor with specific handlers $processor = new ImageProcessor([ IMAGETYPE_JPEG => new JpegHandler(), IMAGETYPE_PNG => new PngHandler(), IMAGETYPE_GIF => new GifHandler(), ]); // Process multiple images $processor->stripExifData('/path/to/image1.jpg'); $processor->stripExifData('/path/to/image2.png'); $processor->stripExifData('/path/to/image3.gif');
Development
Setup
- Clone the repository:
git clone https://github.com/metastrip/image.git
cd image
- Install dependencies:
composer install
Quality Tools
We use three main tools to ensure code quality:
-
PHPUnit - Testing Framework
# Run tests composer test # Generate coverage report composer test:coverage
-
PHP_CodeSniffer - Code Style
# Check coding standards composer cs # Fix coding standards automatically composer cs:fix
-
PHPStan - Static Analysis
# Run static analysis composer stan
Run all checks at once:
composer check
Continuous Integration
Our GitHub Actions workflow automatically runs:
- Tests on PHP 8.0, 8.1, and 8.2
- Code style checks
- Static analysis
- Code coverage reporting
Contributing
Contributions are welcome! Please feel free to submit a Pull Request. By participating in this project, you agree to abide by its terms.
- Fork the repository
- Create a feature branch:
git checkout -b feature-name
- Make your changes
- Run the tests:
composer check
- Commit your changes:
git commit -m 'Add feature'
- Push to the branch:
git push origin feature-name
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.