ingowalther / image-minify-api
0.0.3
2015-11-05 22:08 UTC
Requires
- adambrett/shell-wrapper: 0.6
- doctrine/dbal: 2.5.2
- silex/silex: ~1.3
- symfony/config: 2.7.6
- symfony/console: 2.7.6
- symfony/dependency-injection: 2.7.6
- symfony/yaml: 2.7.6
Requires (Dev)
- phpunit/phpunit: 5.0.*
This package is not auto-updated.
Last update: 2025-01-10 23:25:15 UTC
README
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/)
Installation
Create Database
You should create a database first. In this database Image Minify API will create all necessary tables during composer install.
Install Project
composer create-project ingowalther/image-minify-api %installation-folder-name%
Set permissions for files
chmod a+rw log
Setup Webserver
vHost DocRoot -> web/
Usage
Create API-Key
bin/console user:add
Enter a Username. If the user is created correctly you will see the API-Key in your Terminal.
Compress an Image
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
Response
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==" }
List all user
bin/console user:list
Output:
API-Clients
PHP: https://github.com/ingowalther/image-minify-php-client
Grunt-Task: https://github.com/yannicstadler/image-minify-api-grunt-task
TODO
- Quota