Install an Image-Compression-Service (like TinyPng, JPEGMini) on your own Server!
Currently supports:
- jpeg (mozJpeg, Installation Instructions: http://mozjpeg.codelove.de/binaries.html)
- png (pngquant, https://pngquant.org/)
- svg (SVGO, https://github.com/svg/svgo)
- gif (Gifsicle, https://www.lcdf.org/gifsicle/)
You should create a database first. In this database Image Minify API will create all necessary tables during composer install.
composer create-project ingowalther/image-minify-api %installation-folder-name%
chmod a+rw log
vHost DocRoot -> web/
bin/console user:add
Enter a Username. If the user is created correctly you will see the API-Key in your Terminal.
POST with Params "api_key" and File with Name "image" to http://yourserver/minify
Example:
curl --form "image=@test.jpg" --form api_key=VVDFNNflLIQdCH5vnx0RkmCxxjhHIL6 http://localhost/minify > result.json
You will get a Json-Response like this:
{
"success":true,
"oldSize":539,
"newSize":394,
"saving": 26,
"image":"\/9j\/4AAQSkZJRgABAQAAAQABAAD\/\/gATQ3JlYXRlZCB3aXRoIEdJTVD\/2wCEAAoKCgoKCgsMDAsPEA4QDxYUExMUFiIYGhgaGCIzICUgICUgMy03LCksNy1RQDg4QFFeT0pPXnFlZXGPiI+7u\/sBCgoKCgoKCwwMCw8QDhAPFhQTExQWIhgaGBoYIjMgJSAgJSAzLTcsKSw3LVFAODhAUV5PSk9ecWVlcY+Ij7u7+\/\/CABEIAAEAAQMBIgACEQEDEQH\/xAAUAAEAAAAAAAAAAAAAAAAAAAAH\/9oACAEBAAAAAGb\/xAAUAQEAAAAAAAAAAAAAAAAAAAAA\/9oACAECEAAAAH\/\/xAAUAQEAAAAAAAAAAAAAAAAAAAAA\/9oACAEDEAAAAH\/\/xAAUEAEAAAAAAAAAAAAAAAAAAAAA\/9oACAEBAAE\/AH\/\/xAAUEQEAAAAAAAAAAAAAAAAAAAAA\/9oACAECAQE\/AH\/\/xAAUEQEAAAAAAAAAAAAAAAAAAAAA\/9oACAEDAQE\/AH\/\/2Q=="
}
Parameter | Description |
---|---|
success | true or false |
oldSize | ImageSize before compressing (in Byte) |
newSize | ImageSize after compressing (in Byte) |
saving | The saving of bytes in percent |
image | The binarydata of the compressed image (base64 encoded) |
bin/console user:list
Output:
PHP: https://github.com/ingowalther/image-minify-php-client
Grunt-Task: https://github.com/yannicstadler/image-minify-api-grunt-task
- Quota