dkerner / voronoi-obfuscate
Create an obfuscated version of a source image
dev-master
2022-01-29 15:15 UTC
Requires
- php: ^8.0
This package is not auto-updated.
Last update: 2024-05-19 01:39:15 UTC
README
This is currently a work in progress and not completly stable. API not yet final so new versions can break code.!
voronoi-obfuscate
Create an obfuscated version of a source image by using a Voronoi diagram (see. https://en.wikipedia.org/wiki/Voronoi_diagram)
Getting Started
Maybe you feel like making "art" from your images or you just like your images obfuscated
Input (200x200px):
Results:
Reduce Size to 100x100px
Non proportional resize to 400x100px
Non proportional resize to 100x400px
Installing
composer require dkerner/voronoi-obfuscate "@dev"
Usage
// create an obfuscated version of demo.jpg, store it as out.jpg // and create 500 points VoronoiObfuscator::createFromImagePath('demo.jpg', 'out.jpg', 500); // use config and resize the resulting image $config = new ObfuscatorConfig(); $config->setImagePath('demo.jpg') ->setOutputPath('out.jpg') ->setCellCount(1000) ->setOutputSize(400,800); VoronoiObfuscator::createFromConfig($config);
Or use an image resource as input and output
$config = new ObfuscatorConfig(); // set input $imageRessource = imagecreatefromjpeg('demo.jpg'); $config->setInputResource( $imageRessource ) ->setCellCount(100) ->setOutputSize(100,100); $processedImageRessource = VoronoiObfuscator::processImage($config); // use it further however needed imagejpeg( $processedImageRessource, 'out_processed.jpg');
Authors
- Daniel Kerner - dkerner
License
This project is licensed under the MIT License - see the LICENSE file for details
Acknowledgments
- https://github.com/sroze with the sroze/PHP-Voronoi-algorithm example which was a great starting point and whose Nurbs classes are used at the moment
- https://github.com/zippex who needed the image obfuscation