Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Fast image optimization as a service, based on mozjpeg, written in Swift

License

NotificationsYou must be signed in to change notification settings

allegro/quanta

Repository files navigation

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 usedSwift andVapor 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

Runbrew install mozjpeg.

Linux

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

Installation

Runmake 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).

!!! noteQuanta 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 codeResponseHeaders
200image (binary data)Content-Type: image/jpeg
X-Quanta-Ratio: <float>
400JSON describes errorContent-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

MethodEndpointMethodPurpose
REST-ish API/optimize/jpgPOSTbatch processing
Proxy method/from/?url=<url>&quality=<1..100>GETbatch 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.

NameDescriptionSizePreview
Sample #1a few colors, headings, irrelevant details88 kB (960x252)sample-1
Sample #23 main colors (red, white, black), irrelevant details88 kB (960x252)sample-2
Sample #3a text (black on white), details with various colors508 kB (1600×572)sample-4

Performance

typical_banner_1.jpg

QualityOptimized file sizeElapsed time
6533 kb160 ms
7037 kb149 ms
7542 kb158 ms
8049 kb157 ms
8558 kb168 ms
9071 kb262 ms

Size reduction between 16.889% and 61.0427%.

typical_banner_2.jpg

QualityOptimized file sizeElapsed time
6530 kb257 ms
7034 kb258 ms
7539 kb197 ms
8047 kb179 ms
8555 kb175 ms
9074 kb197 ms

Size reduction between 13.4709% and 64.1687%.

typical_banner_3.jpg

QualityOptimized file sizeElapsed time
65107 kb724 ms
70117 kb722 ms
75130 kb724 ms
80151 kb741 ms
85175 kb730 ms
90217 kb791 ms

Size reduction between 55.7364% and 78.1365%.

Quality comparison

Details

JPEG

ImageOriginalQuality 75
typical_banner_from_showbox.jpeg77 kB55 kB

About

Fast image optimization as a service, based on mozjpeg, written in Swift

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp