I have waveform images stored in a database that need to be displayed and analysed in python. Apparently, these images are stored as hex strings which are compressed with wctZLib method as shown in this extract of the database.
{
"start_dt": "2021-02-01 07:28:35",
"end_dt": "2021-02-01 07:30:49",
"compress_method": "wctZLib",
"waveform_data": "0x789CB57D07BC56D595BD22E8772E88D84BECBD6001E9B ...
}
A sample of the db can be found at github on : https://github.com/Ddest/wctZlib/blob/main/wave.json
I tried googling this compression method in order to decompress and display these images but to no avail.
Even after decompressing it and trying to display it with the PIL library...
with open(filepath,'r') as f:
data=json.load(f)
bytesData=bytearray.fromhex(data['waveform_data'][2:])
image = Image.open(io.BytesIO(zlib.decompress(bytesData)))
image.show()
...It didn't work :
Traceback (most recent call last):
File "/home/usx/Desktop/decompress.py", line 24, in <module> main()
File "/home/usx/Desktop/decompress.py", line 12, in main
image = Image.open(io.BytesIO(zlib.decompress(bytesData)))
File "/usr/lib/python3/dist-packages/PIL/Image.py", line 3186, in open
raise UnidentifiedImageError( PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7f5773d6e020>
even trying to handly it as zip file didn't work.
Can someone give me some insight on how to solve this problem?