I think it is not possible to specify image compression when saving it without extension. I would recommend saving it with an extension and then using os.rename():
import os
import cv2
filename = "image.jpg"
img = ...
cv2.imwrite(filename, img)
os.rename(filename, os.path.splitext(filename)[0])
Hope this helps!
source
share