1

I have read a lot of essays and articles about (Compressing Image Algorithm). There are many algorithms which 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! Article In page 3 at this part (Run length code). It's a very EZ and helpful algorithm but I don't know how do I make new format of image. 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, .bmp

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

  • What do you need your format for? Do you want to compare the efficiency of your implementation (size/speed/loss) against another compression? Or do you just what some own way to store and load images? The second can be achieved by python serialization with pickle module. Just dump your image data with pickle and load. If you want fairly compare size your compression you need to save binary data with open(filename, "wb") – Askold Ilvento Nov 21 '20 at 13:16
  • Hi again! I'm going to compress an image with my own code and algorithm with a low size, good resolution and fast! I'm not going to create this for loading image I told that it is for compression. So I don't need to compress it with 2 or 3 lines of code because I know it doesn't mean to me. Thanks to introduce this module but I don't want it because I can do it with numpy module and CV2. And in this essay it is said to compress it with less elements :) I don't know if I answer your question. I hope it was helpful for you :))) – mobin she84 Nov 22 '20 at 17:28

1 Answers1

0

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

  • read the format from disk into a Numpy array, and
  • write an image contained in a Numpy array to disk

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.

Mark Setchell
  • 191,897
  • 31
  • 273
  • 432
  • Thanks for your question. I was wondering how to open a new file with (Photos app) but I think it is a good way to open it with python code which I wrote it! Thanks a lot :) – mobin she84 Nov 24 '20 at 06:46