All Projects → saharNooby → qoi-java

saharNooby / qoi-java

Licence: MIT license
A pure Java 8 implementation of Quite OK Image Format

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to qoi-java

winston-dev-console
Winston@3 console format aimed to improve development UX
Stars: ✭ 88 (+193.33%)
Mutual labels:  format
table
Produces a string that represents slice data in a text table, inspired by gajus/table.
Stars: ✭ 130 (+333.33%)
Mutual labels:  format
cfmt
Small library for simple and convenient formatted stylized output to the console.
Stars: ✭ 46 (+53.33%)
Mutual labels:  format
JOpenCTM
Java implementation of the openCTM Mesh compression file format
Stars: ✭ 13 (-56.67%)
Mutual labels:  format
googlejavaformat-action
GitHub Action that formats Java files following Google Style guidelines
Stars: ✭ 66 (+120%)
Mutual labels:  format
con
A simple, fast and readable JSON-compatible serialization format
Stars: ✭ 22 (-26.67%)
Mutual labels:  format
phpF
Format PHP code
Stars: ✭ 34 (+13.33%)
Mutual labels:  format
stbi-sharp
C# wrapper around stb_image.h and qoi.h
Stars: ✭ 17 (-43.33%)
Mutual labels:  qoi
elm-format-number
✨Format numbers as pretty strings
Stars: ✭ 56 (+86.67%)
Mutual labels:  format
vue-translated
Internationalization (i18n) and localization (l10n) library for Vue.js v2.
Stars: ✭ 19 (-36.67%)
Mutual labels:  format
sail
The missing small and fast image decoding library for humans (not for machines) ⛵ https://sail.software
Stars: ✭ 206 (+586.67%)
Mutual labels:  qoi
react-native-styled-text
Styled Text for React Native
Stars: ✭ 57 (+90%)
Mutual labels:  format
format-date
📆 A small library (around 400 B when gziped & minified) to format JavaScript `Date` object using same tokens as moment.
Stars: ✭ 25 (-16.67%)
Mutual labels:  format
format-number
文本框数字格式化
Stars: ✭ 17 (-43.33%)
Mutual labels:  format
date-format
A reliable way to format dates and times in Elm.
Stars: ✭ 48 (+60%)
Mutual labels:  format
timelite
String date and time utilities 🕙
Stars: ✭ 17 (-43.33%)
Mutual labels:  format
romans
A Simple PHP Roman Numerals Library
Stars: ✭ 40 (+33.33%)
Mutual labels:  format
bcp-47-normalize
Normalize, canonicalize, and format BCP 47 tags
Stars: ✭ 16 (-46.67%)
Mutual labels:  format
unicode-formatter
Convert portions of text to fancy text using unicode fonts for use on Twitter and other sites that don't support rich text
Stars: ✭ 31 (+3.33%)
Mutual labels:  format
Bali
A fast and lightweight .Net library for reading and writing .class files.
Stars: ✭ 35 (+16.67%)
Mutual labels:  format

QoiSharp

qoi-java

A pure Java 8 implementation of Quite OK Image Format.

This library has no runtime dependencies, including Java AWT. ImageIO/BufferedImage support is provided using separate module qoi-java-awt.

Performance

On average, when using qoi-java-awt as an ImageIO plugin, QOI can encode 7 times faster than PNG with default settings and decode 2 times faster, while having 15% less size than PNG.

To get maximum performance, you can skip ImageIO and use pixel data arrays directly.

See full results in BENCHMARK.md.

Before choosing or rejecting QOI for your project, it is recommended to run benchmarks yourself with appropriate sample files. Here is benchmark code used to produce above results.

How to Use

Add as a dependency

This library is available in Maven Central.

Maven

<dependency>
    <groupId>me.saharnooby</groupId>
    <artifactId>qoi-java</artifactId>
    <version>1.2.1</version>
</dependency>
<!-- Also add this, if you want to use QOI with ImageIO -->
<dependency>
    <groupId>me.saharnooby</groupId>
    <artifactId>qoi-java-awt</artifactId>
    <version>1.2.1</version>
</dependency>

Gradle

dependencies {
	implementation 'me.saharnooby:qoi-java:1.2.1'
	// Also add this, if you want to use QOI with ImageIO
	implementation 'me.saharnooby:qoi-java-awt:1.2.1'
}

Other build systems

You can download prebuilt JARs from GitHub releases or build them yourself.

Usage

Use methods in class me.saharnooby.qoi.QOIUtil:

// Read image from a file
QOIImage image = QOIUtil.readFile(new File("image.qoi"));

System.out.println("Image size: " + image.getWidth() + " x " + image.getHeight());

// Access pixel data
System.out.println("Red channel is " + image.getPixelData()[0]);

// Create new 1x1 RGBA image from raw pixel data
byte[] pixelData = {(byte) 255, 127, 0, (byte) 255};

QOIImage orangeImage = QOIUtil.createFromPixelData(pixelData, 1, 1, 4);

// Write image to a file
QOIUtil.writeImage(orangeImage, new File("orange.qoi"));

Usage with ImageIO

To use QOI with ImageIO, you need to also add qoi-java-awt dependency. It provides an ImageIO plugin, which installs automatically using service provider mechanism.

To read and write QOI images, use standard ImageIO methods:

// Read QOI image from a file
BufferedImage image = ImageIO.read(new File("image.qoi"));

Objects.requireNonNull(image, "Invalid QOI image");

// Write QOI image into a file
if (!ImageIO.write(image, "QOI", new File("copy.qoi"))) {
	throw new IllegalStateException("Image type is not supported");
}

To convert QOI images into BufferedImages and back, use methods in class me.saharnooby.qoi.QOIUtilAWT:

// Convert PNG to QOI
BufferedImage image = ImageIO.read(new File("image.png"));
QOIImage qoi = QOIUtilAWT.createFromBufferedImage(image);
QOIUtil.writeImage(qoi, new File("image.qoi"));

// Convert QOI to PNG
QOIImage secondImage = QOIUtil.readFile(new File("second-image.qoi"));
BufferedImage convertedImage = QOIUtilAWT.convertToBufferedImage(secondImage);
ImageIO.write(convertedImage, "PNG", new File("second-image.png"));

Building

You will need Git, Maven and JDK 8 or higher.

git clone https://github.com/saharNooby/qoi-java.git
cd qoi-java
mvn clean install

Compatibility

No AWT classes are used, so it should be compatible with Android. Please report compatibility issues, if they arise.

Versioning

This project uses semantic versioning.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].