GithubHelp home page GithubHelp logo

qoi-image-compression's Introduction

Build Status

QOI image compression

Python implementation of QOI encoder and decoder

QOI format: https://qoiformat.org/

Installation

git clone https://github.com/adusachev/QOI-image-compression.git
python3 -m venv venv
source venv/bin/activate
python3 setup.py install

Usage

  1. Encode: convert png image to qoi image
from qoi_compress import qoi_encoder, qoi_decoder

png_file = "./png_images/doge.png"
qoi_file = "./qoi_images/doge.qoi"  # where to save qoi image

qoi_encoder.run_encoder(png_file, qoi_file)
  1. Decode: import .qoi file into numpy array
from qoi_compress import qoi_encoder, qoi_decoder

qoi_file = "./qoi_images/doge.qoi"

img_decoded, time_elapsed = qoi_decoder.run_decoder(qoi_file)
print(img_decoded)

save decoded image as png:

import numpy as np
from PIL import Image
im = Image.fromarray(img_decoded.astype(np.uint8))
im.save("img_decoded.png")
  1. Test: encode image png_file and save it as qoi_file, then decode qoi_file and compare decoded qoi image with original png image
from qoi_compress.main import run_single_experiment

png_file = "./png_images/doge.png"
qoi_file = "./qoi_images/doge.qoi"

run_single_experiment(png_file, qoi_file)

Benchmarks

Image size Encoding time Decoding time Compression ratio
460x460 0.7 sec 0.3 sec 2.2
1920x1080 5.5 sec 2.5 sec 2.56
3840x2400 42 sec 19 sec 1.83

TODO

Add support for RGBA images

qoi-image-compression's People

Contributors

adusachev avatar

Watchers

 avatar

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.