Skip to content
/ pyflif Public
forked from charun80/pyFLIF

ctypes-based Python wrapper for the original FLIF library

License

Notifications You must be signed in to change notification settings

dniku/pyflif

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pyflif: ctypes-based Python wrapper for Free Lossless Image Format

Build Instructions

Install the dependencies

FLIF dependencies

pyflif dynamically loads the FLIF library. Please ensure that you have it installed, e.g.:

$ ldconfig -p | grep flif
    libflif_dec.so.0 (libc6,x86-64) => /usr/lib/libflif_dec.so.0
    libflif.so.0 (libc6,x86-64) => /usr/lib/libflif.so.0

pyflif dependencies

  • numpy: sudo apt-get install python-numpy (on debian/ubuntu)
  • scipy (optional): sudo apt-get install python-scipy (on debian/ubuntu)
  • opencv (optional): sudo apt-get install python-opencv (on debian/ubuntu)

Installation

pip install --user git+https://github.com/Pastafarianist/pyflif.git

Usage

Decoding

Simple method for single images

import pyflif

# img: numpy array with shape [ WxHx(3 or 4) ]
# dtype in (uint8, uint16)
img = pyflif.read_flif("path/to/image.flif")

Advanced method also for animations

import pyflif

with pyflif.FlifDecoder("path/to/file.flif") as dec:
    # decompress all frames and store them in a list
    allframes = [dec.get_image(idx) for idx in range(dec.num_images())]

Encoding

WARNING: encoding does not work yet.

Simple method for single images

import pyflif

# img: numpy array with shape [ WxHx(3 or 4) ]
# dtype in (uint8, uint16)
pyflif.write_flif("path/to/image.flif", img)

Advanced method also for animations

import pyflif

with pyflif.FlifEncoder("path/to/file.flif") as enc:
    for img in <image source>:
	    # all images should have the same shape [ WxHx(3 or 4) ] and dtype (uint8/uint16)
	    enc.add_image(img)

About

ctypes-based Python wrapper for the original FLIF library

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%