Reference link :Windows To configure libjpeg-turbo And in python Call in
According to the above link, you can go to windows Top configuration libjpeg-turbo. Here you can have a try .
Here you can refer to the link :windows7 64 On the plane ,libjpeg-turbo Installation and use
debugging -> attribute ->c/c++-> routine -> Attach include directory
D:\cplusplus\library\libjpeg-turbo-main
I cmake The installation directory is install, The path here should be modified according to the actual installation .
debugging -> attribute -> The linker -> routine -> Additional Library Directory
,
D:\cplusplus\library\libjpeg-turbo-main\install\Debug
debugging -> attribute -> The linker -> Input -> Additional dependency
jpeg-static.lib
During the test, you need to install in jconfig.h
Copy to the root directory , Otherwise, we will not find . Test code can refer to windows7 64 On the plane ,libjpeg-turbo Installation and use
clone Code :https://github.com/lilohuang/PyTurboJPEG.git
Add the turbojpeg.dll
copy to C:\Windows\System32
Under the table of contents , Secondly, it needs to be modified PyTurboJPEG In the library setup.py
file , take 38~50 That's ok :
DEFAULT_LIB_PATHS = {
'Darwin': ['/usr/local/opt/jpeg-turbo/lib/libturbojpeg.dylib'],
'Linux': [
'/usr/lib/x86_64-linux-gnu/libturbojpeg.so.0',
'/usr/lib64/libturbojpeg.so.0',
'/opt/libjpeg-turbo/lib64/libturbojpeg.so'
],
'FreeBSD': [
'/usr/local/lib/libturbojpeg.so.0',
'/usr/local/lib/libturbojpeg.so'
],
'Windows': ['C:/libjpeg-turbo64/bin/turbojpeg.dll']
}
It is amended as follows :
DEFAULT_LIB_PATHS = {
'Darwin': ['/usr/local/opt/jpeg-turbo/lib/libturbojpeg.dylib'],
'Linux': [
'/usr/lib/x86_64-linux-gnu/libturbojpeg.so.0',
'/usr/lib64/libturbojpeg.so.0',
'/opt/libjpeg-turbo/lib64/libturbojpeg.so'
],
'FreeBSD': [
'/usr/local/lib/libturbojpeg.so.0',
'/usr/local/lib/libturbojpeg.so'
],
'Windows': ['turbojpeg.dll']
}
cd
To install PyTurboJPEG Under the root directory , perform
python setup.py install
from turbojpeg import TurboJPEG, TJPF_GRAY, TJSAMP_GRAY, TJFLAG_PROGRESSIVE, TJFLAG_FASTUPSAMPLE, TJFLAG_FASTDCT
if __name__ == "__main__":
in_file=open(r"D:\data\face\good3\1630905185050.jpeg","rb")
out_file=open("test.jpg",'wb')
jpeg = TurboJPEG()
img=jpeg.decode(in_file.read())
img=jpeg.encode(img,quality=80)
out_file.write(img)
Windows Next PyTurboJPEG And opencv Compression algorithm speed comparison
It can be seen that libjpeg The algorithm speed is better than opencv Its own compression algorithm ...