简体   繁体   English

Windows上的PIL和JPEG库

[英]PIL and JPEG library on Windows

I have built Python's PIL library from source (due to an error in the version installed from the installer executable) and can create Image() objects from jpg files on the build computer, however when I package this Python application using PyInstaller, the application is unable to open JPEG images. 我已经从源代码构建了Python的PIL库(由于从安装程序可执行文件安装的版本中存在错误),并且可以从生成计算机上的jpg文件创建Image()对象,但是当我使用PyInstaller打包此Python应用程序时,该应用程序无法打开JPEG图像。 Have I not built PIL correctly, as described at PIL encoder jpeg not available , or is something else wrong? PIL编码器jpeg所述,我是否没有正确构建PIL,还是有其他问题?

Update: The error message is "IOError: encoder jpeg not available". 更新:错误消息是“ IOError:编码器jpeg不可用”。

Edit: The problem with the version installed from the installer executable (for both versions 1.1.7 and 1.1.6, if not earlier ones, too) is that it links against the VC90.DebugCRT library/assembly, which I don't is meant to be distributed and which PyInstaller could not find on my system (though a version was there). 编辑:从安装程序可执行文件安装的版本问题(对于1.1.7和1.1.6,如果不是更早的版本也是如此)是它链接到VC90.DebugCRT库/程序集,我不是意味着可以分发,而PyInstaller在我的系统上找不到(尽管有一个版本)。

You need to include the jpeg encoder/decoder dll with your installation, otherwise it won't work on systems that doesn't already have it. 您需要在安装中包括jpeg编码器/解码器dll,否则它将在尚未安装的系统上不起作用。

Haven't tried this myself, but you might also be able to do this by static linking instead by running the configure script with --enable-static. 我自己还没有尝试过,但是您也可以通过静态链接来执行此操作,而不必使用--enable-static运行configure脚本。

You have 2 choices: 您有2个选择:

  1. use PIL's prebuilt binaries from http://www.pythonware.com/products/pil/ 使用http://www.pythonware.com/products/pil/中的 PIL预先构建的二进制文件

  2. build from source (Note you have to setup JPEG library before get JPEG support, it's not easy on windows) 从源代码构建(请注意,必须先设置JPEG库才能获得JPEG支持,在Windows上这并不容易)

References ( not necessary for solving your problem ): 参考(对于解决您的问题不是必需的):

Please ensure that pillow, a fork of the the Python Imaging Library (PIL), gets installed with JPEG support. 请确保安装了枕头,它是Python Imaging Library(PIL)的一个分支,并已安装JPEG支持。 Supported formats are printed when pillow is first installed. 首次安装枕头时,会打印支持的格式。 Instructions on how to get JPEG support are highly platform specific, but guides for PIL should work for pillow as well. 有关如何获得JPEG支持的说明高度针对特定平台,但PIL指南也应适用于枕头。 Generally speaking, you need to ensure that libjpeg-dev is installed and found during installation . 一般来说, 您需要确保安装了libjpeg-dev并在安装过程中找到它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM