Giter Club home page Giter Club logo

reimage's Introduction

reImage

Features

  1. No os.exec call of pngquant or mozjpeg. Only bindings to libraries.
  2. Using libvips for fast image resizing
  3. Docker container uses libvips compiled with mozjpeg instead of libjpeg-turbo. MozJPEG makes tradeoffs that are intended to benefit Web use cases and focuses solely on improving encoding, so it's best used as part of a Web encoding workflow.
  4. png images are optimized with libimagequant (backend library of pngquant)

Install steps

  1. Deploy it with Docker
  2. Configure frontend
  3. Enjoy!

Deploy

  1. Pull docker container: docker pull larrabee/reimage:1.2.5
  2. Run it with docker run -d -p 7075:7075 larrabee/reimage:1.2.5 or use docker-compose config:
version: '2.2'
services:
  reImage:
    image: larrabee/reimage:1.2.5
    restart: always
    ports:
      - "7075:7075"  

Configure frontend

This is basic Nginx config for online resizing with nginx cache.

http {
    proxy_cache_path /var/www/resize_cache levels=1:2 
    keys_zone=resized_img:64m inactive=48h max_size=5G use_temp_path=off;

    server {
        listen       80;
        server_name  example.com;
        root /var/www/example.com/;

        location /img/ {
           location ~* \.(jpg|jpeg|png|ico)(\@[0-9xX]+)$ {
             proxy_pass http://localhost:7075; #Node with running image resizer
             proxy_set_header X-RESIZE-SCHEME "http";
             proxy_set_header X-RESIZE-BASE "example.com";
             #Nginx cache. Optional
             proxy_cache_valid  200 48h;
             proxy_cache_valid  404 400 5m;
             proxy_cache_valid 500 502 503 504 10s;
             add_header X-Cache-Status $upstream_cache_status;
             proxy_cache resized_img;
           }
        }
    }
}

Required options:

  1. Replace localhost:7075 with your hostname and port if you ran resizer in different node.
  2. Set X-RESIZE-SCHEME "http" if your image server with original images run over http (by default use https).
  3. Set you image server hostname here: X-RESIZE-BASE "example.com"

Optional:

  1. Set X-RESIZE-QUALITY header if you want to override quality settings. Default value: 80, allowed values: 1-100
  2. Set X-RESIZE-COMPRESSION header if you want to override compression settings. Default value: 6, allowed values: 0-9

Enjoy!

Benchmark

See benchmark Wiki page

LICENSE

MIT

reimage's People

Contributors

larrabee avatar denji avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.