擅长:python、mysql、java
<p>您可以看看<a href="https://github.com/lilohuang/PyTurboJPEG" rel="nofollow noreferrer">PyTurboJPEG</a>,它是一个<a href="https://github.com/libjpeg-turbo/libjpeg-turbo" rel="nofollow noreferrer">libjpeg-turbo</a>的Python包装器,在解码大型JPEG图像时,它的重新缩放速度非常快(1/2、1/4、1/8)。在</p>
<pre><code>from turbojpeg import TurboJPEG
# specifying library path explicitly
# jpeg = TurboJPEG(r'D:\turbojpeg.dll')
# jpeg = TurboJPEG('/usr/lib64/libturbojpeg.so')
# jpeg = TurboJPEG('/usr/local/lib/libturbojpeg.dylib')
# using default library installation
jpeg = TurboJPEG()
# direct rescaling 1/2 while decoding input.jpg to BGR array
in_file = open('input.jpg', 'rb')
bgr_array_half = jpeg.decode(in_file.read(), scaling_factor=(1, 2))
in_file.close()
</code></pre>