![](/img/trans.png)
[英]How to install OpenJPEG on MacOS, for use with JP2 files and Pillow
[英]Working with JP2 Image on Python Pillow
我正在尝试使用python枕头成像库来处理我的jp2图像。
我按照以下步骤操作:
brew安装libjpeg
brew install openjpeg
sudo pip安装枕头
我只是有.jp2文件的问题。 可能是什么问题?
我收到错误的代码:
from PIL import Image
im = Image.open("sample_1.jp2")
im.show()
我尝试显示图像时出现以下错误日志:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 1746, in show
_show(self, title=title, command=command)
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 2501, in _show
_showxv(image, **options)
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 2506, in _showxv
ImageShow.show(image, title, **options)
File "/Library/Python/2.7/site-packages/PIL/ImageShow.py", line 51, in show
if viewer.show(image, title=title, **options):
File "/Library/Python/2.7/site-packages/PIL/ImageShow.py", line 77, in show
return self.show_image(image, **options)
File "/Library/Python/2.7/site-packages/PIL/ImageShow.py", line 96, in show_image
return self.show_file(self.save_image(image), **options)
File "/Library/Python/2.7/site-packages/PIL/ImageShow.py", line 92, in save_image
return image._dump(format=self.get_format(image))
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 581, in _dump
self.load()
File "/Library/Python/2.7/site-packages/PIL/Jpeg2KImagePlugin.py", line 206, in load
ImageFile.ImageFile.load(self)
File "/Library/Python/2.7/site-packages/PIL/ImageFile.py", line 203, in load
d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
File "/Library/Python/2.7/site-packages/PIL/Image.py", line 420, in _getdecoder
raise IOError("decoder %s not available" % decoder_name)
IOError: decoder jpeg2k not available
我想我发现了问题......
我们为轮式格式的每个受支持的Python版本提供OS X的二进制文件。 这些包括对除OpenJPEG之外的所有可选库的支持。
我想唯一的解决方法是从源码安装Pillow。
作为与该问题没有直接关系的旁注,从源代码安装后,我收到了一个不同的错误:
Nicolas$ python selftest.py
Traceback (most recent call last):
File "selftest.py", line 11, in <module>
from PIL import Image, ImageDraw, ImageFilter, ImageMath
File "/Users/Nicolas/Downloads/Pillow-3.1.0/PIL/Image.py", line 66, in <module>
from PIL import _imaging as core
ImportError: cannot import name _imaging
所以我不知道这是否有效。 如果我设法让它工作,将更新。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.