pythonpython-imaging-libraryopencvimage-compression

How to create an new format of image?


I have read a lot of essays and articles about "Compressing Image Algorithm". There are a lot of algorithms but I can only understand some of them because I'm a student and I haven't gone to high school yet. I read this article which it helps me a lot! In page 3 at this part (Run length code). It's a very easy and helpful algorithm but I don't know how to make a new image format. I am a Python developer but I don't know how to make a new format which it has a separate algorithm and program like jpeg, jpg, png and bmp.

(Sorry I have studied English for 1 year so if I have some problems such as grammar or vocabulary just excuse me.)


Solution

  • Sure, you can make your own image file format. Choose a filename extension, define how it will be stored and write Python code to:

    That way you will be interoperable with all the major image processing libraries such as OpenCV, scikit-image, PIL, wand.

    Have a look how NetPBM works to get started with a simple format. Maybe look at PCX format if you like the thought of RLE.

    Read up on how to write binary to a file with Python.