Giter VIP home page Giter VIP logo

quanta's Introduction

Quanta - image optimization service

test

Quanta is a microservice for JPEG image optimizations built using Swift programming language. It is similar to other online tools like jpegmini.com, tinypng.com or compressor.io but it is an in-house solution and based on a proven solution like MozJPEG.

Compared with other mozjpeg wrappers, this software has low memory overhead and fast performance, which can help with horizontal scaling with a large number of instances and simultaneous requests.

More information

We used Swift and Vapor 3 to handle HTTP requests. Check also excellent libraries without which quanta can't work:

Requirements

Quanta requires MozJPEG to be installed on host.

MacOS

Run brew install mozjpeg.

Linux

You can use the provided script install-linux-dependencies.sh to compile and install mozjpeg. Also, follow official documentation in the repository: https://github.com/mozilla/mozjpeg

Installation

Run make to compile the software.
Go to .build/release/ directory and run ./quanta.

Getting started

There are multiple ways to use Quanta to recompress the JPEG file:

  • REST(-ish) API
  • proxy method
  • via GUI

REST(-ish) API

Quanta provides REST API. This simple endpoint optimizes image by normal HTTP request and returns image (JPEG).

!!! note Quanta always preserves original format. If you send JPEG - you will get (optimized) JPEG.

Usage

$ curl -x POST https://quanta.com/optimize/jpg/ -H "Content-Type" \
    --form fileBytes=@/tmp/file_to_optimize.jpg
    --form quality=75
    --output /tmp/optimized_file.jpg

According to the table below, as a result, you can get binary data or JSON struct with an error message.

Status code Response Headers
200 image (binary data) Content-Type: image/jpeg
X-Quanta-Ratio: <float>
400 JSON describes error Content-Type: application/json

Proxy method

The easiest way to integrate with an external system because quanta get an external resource and processing it and send you optimized version.

Usage

$ export IMAGE_TO_OPTIMIZE=https://quanta.com/images/quanta.jpg
$ curl -x GET https://quanta.com/from/?url=$IMAGE_TO_OPTIMIZE&quality=20

GUI

Simple UI allows you to upload pictures and compare various compressions settings.

Summary

Method Endpoint Method Purpose
REST-ish API /optimize/jpg POST batch processing
Proxy method /from/?url=<url>&quality=<1..100> GET batch processing
or quick preview
GUI - - one-time optimization

Benchmarks

In this section, you will find information about the performance of quanta. All samples are from the production of Allegro.

Name Description Size Preview
Sample #1 a few colors, headings, irrelevant details 88 kB (960x252) sample-1
Sample #2 3 main colors (red, white, black), irrelevant details 88 kB (960x252) sample-2
Sample #3 a text (black on white), details with various colors 508 kB (1600ร—572) sample-4

Performance

typical_banner_1.jpg

Quality Optimized file size Elapsed time
65 33 kb 160 ms
70 37 kb 149 ms
75 42 kb 158 ms
80 49 kb 157 ms
85 58 kb 168 ms
90 71 kb 262 ms

Size reduction between 16.889% and 61.0427%.

typical_banner_2.jpg

Quality Optimized file size Elapsed time
65 30 kb 257 ms
70 34 kb 258 ms
75 39 kb 197 ms
80 47 kb 179 ms
85 55 kb 175 ms
90 74 kb 197 ms

Size reduction between 13.4709% and 64.1687%.

typical_banner_3.jpg

Quality Optimized file size Elapsed time
65 107 kb 724 ms
70 117 kb 722 ms
75 130 kb 724 ms
80 151 kb 741 ms
85 175 kb 730 ms
90 217 kb 791 ms

Size reduction between 55.7364% and 78.1365%.

Quality comparison

Details

JPEG

Image Original Quality 75
typical_banner_from_showbox.jpeg 77 kB 55 kB

quanta's People

Contributors

adamdubiel avatar ar4s avatar iceener avatar mkuzmik avatar vi4m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

quanta's Issues

Tests support for mozjpeg 3 and mozjpeg 4

Mozjpeg 4 compiles fine with upgraded quanta, but we haven't provided tests cases (optimization outputs) for newer version.
Consider making separate tests cases for 3 and 4 if we want support both versions.

GUI screenshot

@ar4s we need a screenshot for the GUI - it's missing in README, but it's so cool to use!

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.