mrcnpdlk/image-web-tool

Image Web Manipulator

v0.1.1 2018-01-22 15:34 UTC

This package is not auto-updated.

Last update: 2024-04-15 18:45:55 UTC


README

Simple image web tool manipulation package - other than all.

Instalation

The best way is cloning the repo with specific branch name. Stable releases are sown here.

git clone -b {STABLE_VERSION} https://github.com/mrcnpdlk/image-web-tool.git

Configuration

In folder config copy file config.json.dist and rename to config.json. Edit file and set or delete options:

  • storage - path to the folder with pictures
  • font - path to the ttf file with font. Used as font on placeholders files.
  • debug - if TRUE no placeholder, but exception stack is shown.

Default font BlowBrush is included to the project.

Caching

For better performance for each request cache is used. REDIS if enabled. If not FILES is used.

Request url schema

Example

http://example.com/iwt/v1/{params}/{fileName}

params and fileName are passed to the api.php file.

Request Options (params)

Option Description Values Notes
w width value in px
h height value in px
c crop mode enum: scale,fit,fit-margin,fill
q quality 0-100 only JPG format supported
r rotate angle in degrees
bgc background color HEX format
e effect enum: g (gamma), n (negative), gr (grayscale), c (colorize), b (blur)
eo effect option string,int - depends on effect type, see table below
Effect [e] Description Option [eo] Default
g gamma gamma correcion 1
n negative
gr grayscale
c colorize color in HEX format #FFFFFF
b blur sigma 1

Nginx Configuration

server {
    listen 127.0.0.1:9081 default_server;

    root API_DIR_LOCATION;

    index api.php;

    server_name _;

    location / {
        try_files $uri $uri/ /api.php?$args;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        }
}
server {
    ## LISTEN
    listen 81;

    ## SERVER
    server_name example.com;

    root ROOT_DIR;
    index index.php index.html index.htm index.nginx-debian.html;

    location /iwt/v1 {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;

        rewrite ^/iwt/v1/?(.*) /$1 break;

        access_log /var/log/nginx/iwt-access.log;
        error_log /var/log/nginx/iwt-error.log;

        proxy_pass http://127.0.0.1:9081;
        proxy_redirect off;
    }

Examples

/h_100/demo.jpg

Height is set. Default FIT crop mode is enabled.

alt text

/h_200,e_b,eo_5/demo.jpg

Blur effect.

alt text

/h_200,e_b,eo_5/demo.jpg

Colorization effect with pink color.

alt text

/h_200,e_n/demo.jpg

Negative effect.

alt text

/h_200,q_2/demo.jpg

Less quality.

alt text

/h_200,w_200,c_fill/demo.jpg

FILL mode.

alt text

/h_200,w_200,c_fit/demo.jpg

FIT mode.

alt text

/h_200,w_200,c_fit-margin/demo.jpg

FIT MARGIN mode.

alt text

/h_200,w_200,r_20/demo.jpg

ROTATE mode.

alt text

/w_200,h_100/demo.jpg

File not found. Placeholder is shown.

alt text

/w_200,h_100/demo.jpg

Placeholder is shown.

alt text