• Stars
    star
    376
  • Rank 111,381 (Top 3 %)
  • Language
    Shell
  • License
    Other
  • Created about 11 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A Bash script to automate adaptive JPEG compression using common CLI tools

Adept - the adaptive JPG Compressor

Quick Start

  • Please install a MSS saliency algorithm binary, ImageMagick, MozJPEG and JPEGrescan
  • Make MozJPEG available as "mozjpeg" in your $PATH, e.g. via symlink
  • Fetch a copy of adept and place it somewhere you deem a good place for 3rd party shellscripts, e.g. "/usr/local/bin". Make sure the location is in the $PATH of the user(s) who will run adept and ensure that the script is executable (chmod -x).
  • Symlink it as "adept" for your own convenience
  • Now you can run "adept /path/to/image.jpg" to compress JPEGs far more effectively!

Introduction

When compressing JPEG images, the same compression level is used on the entire image. However, most JPEG images contain homogeneous and heterogeneous areas, which are varyingly well-suited for compression. Compressing heterogeneous areas in JPEGs to reduce filesize causes compression artefacts due to the lossy nature of JPEG compression.

This script adaptively alters the compression level for areas within JPEGs (per-block) to achieve optimized file size while maintaining a decent visual quality. This script achieves a significantly reduced file size compared to standard tools such as cjpeg while maintaining good visual quality, as can be measured via SSIM. This is good news for the Web Performance and thus Web Developer community to achieve a great user experience on websites.

Example

Best quality/size:

$ convert -verbose -quality 100 images/lena.png images/lena.q100.jpg
images/lena.png PNG 512x512 512x512+0+0 8-bit DirectClass 475KB 0.010u 0:00.010
images/lena.png=>images/lena.q100.jpg PNG 512x512 512x512+0+0 8-bit DirectClass 401KB 0.030u 0:00.039

$ ./adept-jpeg.sh images/lena.q100.jpg
./adept-jpeg.sh options: inherit, 69, autodetect, _adept_compress_imagemagick
404266 images/lena.q100.jpg
size=8 512 512
tilecount=64x64
salient=1.04084
salient=74.321
salient=48.2852
salient=36.5063
threshold=43
slice to ram... ok.
estimate content complexity and compress... 4096 tile ok.
final image... ok.
200860 images/lena.q100_adept_compress_imagemagick.jpg (50%)

$ dssim -o images/lena.q100_adept_compress_imagemagick.c.png images/lena.png images/lena.q100_adept_compress_imagemagick.jpg
0.00236562  lena.q100_adept_compress_imagemagick.jpg

PNG JPEG Q=100 ADEPT JPEG DSSIM

PNG -> JPEG Q=100 -> ADEPT JPEG -> Compare (DSSIM)

Contributors

In alphabetical order:

Licence

This software is published under the BSD licence 3.0

Copyright (c) 2015, Tobias Baldauf All rights reserved.

Mail: [email protected] Web: who.tobias.is Twitter: @tbaldauf

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

More Repositories

1

cjpeg-dssim

Instead of relying on the non-standardized quality metric for JPEG compression, let's make use of a dissimilarity check to hone in on an optimal quality setting for each JPEG to be compressed
Shell
199
star
2

slides-in-markdown

Slide deck tool for giving presentations written in MarkDown. Based on remark.js and written in plain HTML, CSS & JS. Features presenter console with speaker notes, timer, screen blanking and more. The theme provides all basic requirements for slide contents (images, video, code snippets etc) and gives you many small helpers to style contents.
CSS
88
star
3

mss-saliency

Implementation of the Maximum Symmetric Surround Saliency algorithm to highlight salient regions of interest within images. The algorithm was originally invented by Radhakrishna Achanta and this release has been created with his expressed permission.
D
37
star
4

Computer-Science-Algorithms

Collection of various algorithms for personal study, implemented in PHP
PHP
33
star
5

php-code-deobfuscator

Bash script to retrieve unobfuscated (unencrypted) PHP code
Shell
24
star
6

simple-website-speed-test

Shell
8
star
7

Unshortener

Unshortens URLs to keep the semantic web alive and give your readers a chance to see where a link is actually taking them. This is especially useful when aggregating microblogging-content.
PHP
4
star
8

server-log-parser-error-reporting

A simple Bash script that you can run e.g. daily via Cron to grab the current access.log from your webserver, parse it and find HTTP error codes to report them. The script can be run from any *NIX machine under your control, be it a monitoring or development server or even your own laptop.
Shell
3
star
9

-Lucas-Sequence-Numbers

This is a small CSS repo based on the post at http://www.webdesignerdepot.com/2012/06/sizing-type-with-lucas-sequences/ to size fonts / headings in CSS based on Fibonacci- / Lucas-numbers sequences
2
star
10

lockdown-maintainance-wordpress-plugin

A WordPress plugin that upon activation notifies all logged-in users of upcoming maintainance and forces their logout after a timer (default: 5 minutes) has expired. Only admin-users can access WordPress after that and all other users attempting to login will be notified of ongoing maintainance. Deactivation of the plugin by the admin lifts all restrictions. This plugin is useful when syncing / deploying a staging-server up to a live-server.
PHP
2
star
11

normsetboiler

A merger between H5BP's CSS Reset + defaults, Normalize.css as well as several smaller snippets & gists. The aim of this project is to create a sensible, consistent, predictable, cross-browser, valid default CSS while maintaining a small selector footprint for performance.
1
star
12

WordPress-Plugin--Password-Security-Checker

A simple WordPress plugin which, when adding / editing users, checks the password for minimum length, the usage of small and capital letters as well as numbers.
PHP
1
star
13

cutler-responsive-fluid-grid-with-fixed-gutters-boilerplate

An opinionated web development boilerplate containing a responsive fluid grid with fixed gutters, many readability enhancements and helper classes. It is focussed on offering components that work well together while providing a very small filesize footprint and no need to overwrite options as often the case with Bootstrap or Foundation.
CSS
1
star