UsingNet / nvjpeg-python

nvjpeg for python
MIT License
93 stars 24 forks source link

Write function doesn't take into account quality #21

Open manuelporta opened 8 months ago

manuelporta commented 8 months ago

Hello there! I'm trying to do some speed tests writting encoded images to disk playing with jpeg quality factor. I'm using the python wrapper for NvJpeg_write as follows:

foo = nj.write('test.jpg', raw, quality)
print(foo)

I have tried with quality = [10, 70, 90] but I'm always obtaining the same buffer/file size (217936 for my case)

Regardless, when I directly use the NvJpeg_encode wrapper I achieve to get the proper sizes:

bar = nj.encode(raw, quality)
print(len(bar))
# 53096 for quality=10, 217936 for quality=70 and 447357 for quality=95

I've looked at the source code and it seems that NvJpeg_write just calls NvJpeg_encode and passes the arguments, but I'm not used at all to C code, so I'm probably missing out something.

Can anyone lend me a hand?