compression

Compressing image with python-opencv actually results more size

Compressing image with python-opencv actually results more size Question: I want to compress image in-memory using python. Using this code from answer https://stackoverflow.com/a/40768705 I expect that changing "quality param" (90) I will get less size of result image. encode_param = [int(cv2.IMWRITE_JPEG_QUALITY), 90] result, enc_img = cv2.imencode(‘.jpg’, img_np, encode_param) My original plan was to decrease this …

Total answers: 1

Parallelization of un-bzipping millions of files

Parallelization of un-bzipping millions of files Question: I have millions of compressed .bz2 files which I need to uncompressed. Can uncompression be parallelized ? I have access to the server with many cpu cores for the purpose. I worked with the following code which is correct but it is extremely slow. import os, glob, bz2 …

Total answers: 3

Is there any efficient way to store large raw data as text in a .py file?

Is there any efficient way to store large raw data as text in a .py file? Question: This may be a little bit confusing, but I will explain. Basically, there is a contest platform for a chess game. Everyone needs to upload only one .py file to it as their own AI program, and matches …

Total answers: 1

What type of encoding/compression is this?

What type of encoding/compression is this? Question: So, I am trying to decode/decompress web socket receive, but I don`t know what should I use, gzip, lib and etc. def on_message(ws, message): print(message) def on_error(ws, error): print(error) def on_close(ws, close_status_code, close_msg): print("### closed ###") def on_open(ws): print("[*] Opened connection.") msg = ["lang", "AA==", "data", "WINLINE", "getdate"] …

Total answers: 1

zlib.error: Error -3 while decompressing data: too many length or distance symbols

zlib.error: Error -3 while decompressing data: too many length or distance symbols Question: Encountering this error for decompressing chunks of a file. I already decompressed successfully about 5 chunks of data. But there is just one range of data that doens’t get decompressed. The header should be right. Header 78 9C This is only a …

Total answers: 1

Python – Including frequency table at the beginning of a Huffman-compressed file

Python – Including frequency table at the beginning of a Huffman-compressed file Question: I am trying to implement Huffman compression and decompression of files, where all the information needed to decompress must be included in the compressed file. For this implementation I want to include the frequency table in the compressed file, such that the …

Total answers: 2

How to zip a file in python?

How to zip a file in python? Question: I have been trying to make a python script to zip a file with the zipfile module. Although the text file is made into a zip file, It doesn’t seem to be compressing it; testtext.txt is 1024KB whilst testtext.zip (The code’s creation) is also equal to 1024KB. …

Total answers: 3

How to detect zstd compression?

How to detect zstd compression? Question: I am currently working on a python application, that works with facebook api’s. As we all know, facebook loves their own technology and is working with zstd for data compression. The problem: facebook is returning either a uncompressed response with normal json or if the response is longer, it …

Total answers: 2

Python: Read compressed (.gz) HDF file without writing and saving uncompressed file

Python: Read compressed (.gz) HDF file without writing and saving uncompressed file Question: I have a large number of compressed HDF files, which I need to read. file1.HDF.gz file2.HDF.gz file3.HDF.gz … I can read in uncompressed HDF files with the following method from pyhdf.SD import SD, SDC import os os.system(‘gunzip < file1.HDF.gz > file1.HDF’) HDF …

Total answers: 2