• Stars
    star
    163
  • Rank 231,141 (Top 5 %)
  • Language
    C++
  • License
    MIT License
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

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

Repository Details

Free Universal Image Format

FUIF development has stopped since FUIF is subsumed in JPEG XL, which is based on a combination of Pik and FUIF. A royalty-free and open source reference implementation of JPEG XL is available on GitHub. For more information, see JPEG XL community page or visit the JPEG XL Discord server.


FUIF: Free Universal Image Format

WARNING: This is a research prototype. The bitstream is not finalized. Images encoded with the current version of FUIF may not (and probably will not) decode with future versions of FUIF. Use at your own risk!

FUIF is a new image format, combining ideas from JPEG, lossless WebP, and FLIF. It is a 'universal' image format in several senses:

  1. it works well for any kind of image (photographic and non-photographic)
  2. it can do both lossless and lossy (with the same underlying algorithm)
  3. it is Responsive By Design: one file can be used, instead of needing separate images for the low-quality image placeholder, thumbnail, preview, dpr 1, dpr 2, etc
  4. it is backwards compatible with JPEG, in the sense that existing JPEG images can be transcoded to FUIF losslessly (no generation loss) and effectively (smaller files)
  5. it can achieve various trade-offs between encode/decode complexity and compression density

In more detail:

1. Any kind of image

FUIF supports several methods for image preprocessing and entropy coding, so it can use the methods that work best for a particular image (or a particular part of an image).

For non-photographic images with few colors, a palette (color index) can be used. There is no limit on the palette size.

For images with repetition (e.g. images that include text, where the same letter shapes appear in multiple locations), an optional transformation can be used to replace repetition with references (somewhat similar to JBIG2).

For photographic images, the DCT transformation can be used.

For raw sensor data, the format supports an arbitrary number of channels, that do not need to have the same dimensions, and that do not need to have the same value ranges either. The actual ranges can be used effectively (not just 8-bit or 16-bit like in PNG, but also things like 14-bit with a black level and white level range of 1023..15600).

FUIF supports bit depths up to 28-bit per channel, unsigned or signed. Only integer values are supported (no floating point), but in principle, floating point numbers can be represented as integers plus a suitable transfer function.

2. Lossless and lossy

FUIF uses reversible transforms (YCoCg, reversible Haar-like squeezing); optional quantization is the only source of loss.

Unlike FLIF, FUIF was designed with lossy compression in mind. Unlike JPEG, FUIF can obtain fully lossless compression. Unlike WebP and JPEG 2000, FUIF uses the same algorithm for both lossy and lossless.

FUIF attempts to offer state-of-the-art compression for both lossy and lossless compression.

3. Responsive By Design

The FUIF bitstream is designed in such a way that truncating a file results in a lower resolution downscaled image. It is similar to progressive JPEG or JPEG 2000 in this respect. Image formats (like WebP, HEIC/BPG, AVIF) that are derived from a video codec (VP8, HEVC, AV1) intra-frame encoding, do not support progressive decoding, since in a video codec it does not make much sense to decode a single frame progressively.

FUIF was designed specifically with web delivery in mind. Instead of having to produce, store and deliver many variants of an image, scaled to various dimensions, the idea is to use a single file and truncate it depending on the dimensions it gets rendered on. This approach has several advantages:

  • Less storage needed (no redundancy)
  • Better for CDNs (cache hit is more likely)
  • Less bandwidth needed (e.g. if you are currently sending a LQIP, then a thumbnail, then when it gets clicked a larger image)
  • Smart browsers could make choices themselves, e.g. load lower resolution when on a slow or expensive connection; when the local browser cache gets too full, instead of deleting whole files, it could trim off bytes at the end, keeping a preview in cache

The header of a FUIF file contains a mandatory list of truncation offsets, which makes it easy to know how many bytes should be requested or served. The following offsets are included in the header:

  • LQIP: the first very low-quality preview of an image (typically at 100-200 bytes)
  • scale 1/16
  • scale 1/8
  • scale 1/4
  • scale 1/2

These power-of-two downscales are exact, in the sense that if you truncate the file at the given offset, the resulting image is the same as decoding the whole full-resolution image and then downscaling it. This cannot really be done in an efficient way with progressive JPEG.

FUIF has a minimalistic, compact header layout, so the first bits of actual image data appear as early as possible. This makes it possible to get a LQIP within a small byte budget, while it is still the beginning of the actual full image, so you also get the actual image dimensions, truncation offsets etc.

4. Backwards compatible with JPEG

There are a LOT of existing JPEG images out there, as well as devices that produce new JPEG images. If the only way to transcode a JPEG image to a new image format, is to decode the JPEG to pixels and encode that to the new format, then there is a problem. Either you get significant generation loss, or you get new files that are actually larger than the original.

FUIF supports the 8x8 DCT transform (which is inherently lossy due to rounding errors) and the YCbCr color transform (which is also inherently lossy for the same reason). This means it can losslessly represent the actual information in a JPEG image, while still adding most of the benefits of FUIF:

  • LQIP and scale 1/16 (progressive JPEG starts at scale 1/8)
  • Minimal header overhead
  • Better compression

Comparing FUIF to Dropbox's Lepton, which also does lossless JPEG recompression:

  • Lepton can obtain slightly better compression density
  • Lepton is faster
  • Lepton is bit-exact (not just image-exact)
  • FUIF can be decoded progressively (Lepton is anti-progressive since it encodes the AC before the DC)
  • FUIF can do more than just what JPEG can, for example you can add an alpha channel to an existing JPEG

5. Trade-offs between complexity and compression density

The entropy coding of FUIF is based on MANIAC (just like FLIF). Different trade-offs between computational complexity and compression density can be obtained. Using predefined or restricted MANIAC trees (or even no trees at all), encoding can be made faster; if encode time is not an issue, then there are many ways to optimize the encoding.

In principle, subsets of the formats ("profiles") could be defined (e.g. by using fixed or restricted transformations and MANIAC trees) for which both encoding and decoding can be specialized (or done in hardware), making it significantly faster. These subsets are not currently defined nor implemented.

FUIF is also well-suited for adaptive compression (i.e. having different qualities in different regions of the image). The MANIAC tree can represent an arbitrary segmentation of the image; there is no notion of (having to align with) macroblocks. This makes it easy to effectively use different context models for different regions of the image.

FUIF Design Principles

The following goals or principles have guided the design of FUIF:

  • FUIF is an image format, not a container. FUIF stores pixels and the metadata needed to render the image, but that's it. Anything else, like Exif metadata, comments, rotation, crop coordinates, layers, tiling, image sequences, and so on is a task for the container format (e.g. HEIF), not for the image format. FUIF does support simple 'filmstrip' animation, so it can be used to recompress GIF and APNG, but it is not a video codec. Rationale: this is a matter of separation of concerns, as well as avoiding duplication of functionality. For simple animations, FUIF might be suitable, but in general we think that most animations should be encoded as a short (looping) video (taking advantage of inter-frame prediction, which is out of the scope of an image format).

  • FUIF is optimized for delivery, not storage. It is progressive / "responsive by design". One single file can be used instead of having to downscale a high-resolution original to various target resolutions. The bitstream does not require seeking and a meaningful placeholder/preview can be shown from the first few hundred bytes. Perhaps it is possible to achieve better compression density and/or faster encoding by not optimizing for delivery (e.g. by predicting DC from AC like Lepton does). If the use case is (essentially) write-only archival then maybe it is worth it to sacrifice progressive decoding, and FUIF can in principle be used in such a way, but that's not the primary target. Rationale: the variety of display devices (from smart watches to huge 8K screens) and network conditions (from 2G on the road in rural areas to very high speed at home) is a huge challenge. Making many files for the same image is not the best approach, e.g. in terms of CDN cache hits. Moreover browsers get few opportunities to be smart and adjust the image resolution and quality automatically based on the device and network conditions. Non-progressive image formats result in a bad user experience when bandwidth is an issue.

  • 'Honest' compression artifacts. There are various approaches to how to do lossy compression. Different techniques lead to different artifacts. Some artifacts are less "annoying" than other artifacts. For example, blurring, smearing and mild ringing are probably not very annoying (or even desireable to some, because it might eliminate noise and increase perceived sharpness), while pixelation, blockiness and color banding are annoying and obvious compression artifacts. Also, some artifacts are not very "honest", in the sense that the image looks deceptively better than it actually is. For example, JBIG2 in lossy mode or HEIC at low bitrates can produce images that look like they are high-quality (e.g. they have sharp details at the pixel level), but they are actually very different from the uncompressed image. For example, JPEG artifacts are "honest" and "annoying", while WebP and HEIC artifacts are "not honest" and "not annoying". FUIF aims for compression artifacts that are "honest" and "not annoying". At low bitrates, pixelation will become obvious at a 1:1 scale, but the overall image fidelity will still be as high as possible (e.g. comparing a downscaled lossy FUIF image to a downscaled original). Rationale: this is a matter of preference, but we think that image fidelity is more important than hiding the fact that lossy compression was used. An image format should not act as an artistic filter that modifies an image more than necessary. At least that's our opinion.

  • FUIF is royalty free and it has a reference implementation that is free and open source software. Rationale: we don't want no patent mess, please.

  • FUIF is legacy-friendly but not backwards compatible. Unlike JPEG XT, the FUIF bitstream is completely different from legacy JPEG, so it is not backwards compatible (cannot be read by existing JPEG decoders). But unlike most other recent image formats (e.g. WebP, HEIC, AVIF), existing JPEG images can be converted losslessly and effectively to FUIF, potentially with added information like alpha or depth channels. Rationale: backwards compatibility is obviously convenient, but it has serious downsides. It implies that the compression density cannot be improved compared to legacy JPEG. It also means that none of the new features (like e.g. alpha) are guaranteed to be rendered correctly, since (at least initially) most decoders will ignore any extensions of the legacy JPEG bitstream. So for these reasons, not being backwards compatible is a better choice. However it is nice to be able to transcode existing JPEG images to FUIF without generation loss and while saving bytes.

TL;DR feature summary

  • Lossless and lossy, works well for photographic and non-photographic
  • Arbitrary number of channels (grayscale, RGB, CMYK, RGBA, CMYKA, CMYKA+depth, etc)
  • Bit depth up to 28-bit, arbitrary actual ranges of pixel values
  • Progressive/Responsive by design: single-file responsive images
  • Minimal header overhead, so LQIP in say a 200-byte budget is possible
  • Backwards compatible with JPEG (can losslessly and efficiently represent legacy JPEG files)
  • Adjustable trade-off between encode/decode complexity and compression density

More Repositories

1

cloudinary_npm

Cloudinary NPM for node.js integration
JavaScript
623
star
2

cloudinary-react

React components that utilize Cloudinary functionality
JavaScript
500
star
3

responsive_breakpoints_generator

JavaScript
437
star
4

cloudinary_gem

Cloudinary GEM for Ruby on Rails integration
Ruby
420
star
5

cloudinary_php

PHP extension for Cloudinary
PHP
380
star
6

cloudinary_js

Cloudinary JavaScript library
CSS
328
star
7

cloudinary_angular

Cloudinary Angular client library
TypeScript
305
star
8

pycloudinary

Python package for cloudinary
Python
249
star
9

cloudinary_ios

Cloudinary iOS SDK
Swift
164
star
10

cloudinary_java

Cloudinary Java Client Library
Java
160
star
11

ssimulacra2

SSIMULACRA 2. Perceptual metric.
C++
141
star
12

cloudinary-vue

Cloudinary components library for Vue.js application, for image and video optimization.
JavaScript
99
star
13

CloudinaryDotNet

Cloudinary DotNet library
C#
98
star
14

ssimulacra

C++
93
star
15

cloudinary-video-player

Cloudinary Video Player
JavaScript
70
star
16

cloudinary_android

Android client for integrating with Cloudinary
Java
66
star
17

pkg-cloudinary-core

Distribution repository for the Cloudinary JavaScript library. Cloudinary is an end-to-end solution for all your image and video needs.
JavaScript
54
star
18

js-url-gen

Cloudinary's base javascript library, including URL generation.
HTML
47
star
19

frontend-frameworks

Cloudinary javascript frontend frameworks SDKs, including Shared HTML layer, Angular, React and Vue SDKs
TypeScript
41
star
20

cloudinary_wordpress

Cloudinary's WordPress plugin
PHP
39
star
21

cloudinary-go

Cloudinary Golang package
Go
36
star
22

cloudinary_android_parse_sample

Sample Android photo album app with Cloudinary using Parse as backend
Java
24
star
23

cloudinary_parse

Cloudinary Parse Module for easy integration
JavaScript
22
star
24

cloudinary_pubnub_demo

Demo for uploading images to Cloudinary and sharing them in real-time using PubNub
JavaScript
18
star
25

cloudinary-cli

A command line interface for Cloudinary's APIs
Python
17
star
26

cloudinary-svelte

Cloudinary components library for Svelte
JavaScript
17
star
27

cloudinary_scala

Cloudinary Scala Client Library
Scala
16
star
28

cloudinary_magento

Cloudinary's Magento extension. Upload product images to the cloud, manipulate them to match your graphic design and optimize images for better user experience
PHP
16
star
29

wdio-allure-ts

WebdriverIO, Allure reporter and TypeScript wrapper for UI E2E testing
TypeScript
15
star
30

cloudinary_magento2

Cloudinary's Magento 2 extension. Upload product images to the cloud, manipulate them to match your graphic design and optimize images for better user experience
PHP
15
star
31

pkg-cloudinary-jquery

Distribution repository for the Cloudinary JavaScript library and jQuery Plugin. Cloudinary is an end-to-end solution for all your image and video needs.
JavaScript
11
star
32

cloudinary_kotlin

Cloudinary Kotlin SDK library
Kotlin
10
star
33

cloudinary_sap_commerce

Cloudinary's SAP Commerce Extension
Java
9
star
34

android-demo

Java
9
star
35

cloudinary-react-native

TypeScript
9
star
36

pkg-cloudinary-jquery-file-upload

Distribution repository for the Cloudinary jQuery File Upload library. Cloudinary is an end-to-end solution for all your image and video needs.
JavaScript
9
star
37

web-speed-test-server

Page Speed Image Performance Analysis (Server)
JavaScript
8
star
38

web-speed-test-client

Page Speed Image Performance Analysis
JavaScript
8
star
39

cloudinary_sfcc_pagedesigner

Cloudinary Salesforce PageDesigner Integration
JavaScript
8
star
40

cloudinary_dart

Dart
7
star
41

bower-cloudinary

Cloudinary JavaScript bower package
JavaScript
6
star
42

cloudinary-js-streaming

Cloudinary Live Streaming Javascript SDK
JavaScript
6
star
43

cloudinary_flutter

Dart
6
star
44

cloudinary_tinymce

TinyMCE plugin for adding and manipulating images from Cloudinary's cloud-based media library
JavaScript
5
star
45

php-transformation-builder-sdk

Cloudinary PHP Transformation Builder SDK
PHP
3
star
46

mailinary

scrape and email web pages on schedule or on demand
JavaScript
3
star
47

cloudinary_titanium

Cloudinary integration library for Appcelerator Titanium
JavaScript
3
star
48

cloudinary_sfcc_site_cartridge

Salesforce Commerce Cloud integration
JavaScript
3
star
49

cloudinary-video-analytics

JavaScript
2
star
50

cloudinary-ios-sample-app

Cloudinary iOS sample application
Swift
2
star
51

product-customization-sample-app

JavaScript
2
star
52

imagemagick_blog

Complementary source code to Cloudinary's ImageMagick blog post
Ruby
2
star
53

cloudinary_chrome_extension

Cloudinary's Chrome extension for web developers
2
star
54

cloudinary_cake_php

Cloudinary CakePHP module
PHP
2
star
55

js-transformation-builder-sdk

TypeScript
2
star
56

media-management-js

JavaScript
2
star
57

vue-cli-plugin-cloudinary

Plugin of Cloudinary Vue SDK for Vue CLI
JavaScript
2
star
58

media-editing-js

JavaScript
1
star
59

cloudinaryNodeMongo

Upload images to Cloudinary and display previously uploaded images in a grid
JavaScript
1
star
60

cloudinary-live-demo

JavaScript
1
star
61

cloudinary_commercetools

Cloudinary demo for Commercetools
TypeScript
1
star
62

live-streaming-demo

Demo of live video streaming using video streaming sdk
JavaScript
1
star
63

account-provisioning-php

Cloudinary Account Provisioning PHP SDK
PHP
1
star
64

media-editing-api-php

Cloudinary Media Editing API PHP SDK
PHP
1
star
65

media-editing-java

1
star