Skip to content

ingowalther/image-minify-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Minify API

Install an Image-Compression-Service (like TinyPng, JPEGMini) on your own Server!

Build Status

Currently supports:

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=="
}
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)

List all user

 bin/console user:list

Output:

Console 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