<legend id='P7r9O'><style id='P7r9O'><dir id='P7r9O'><q id='P7r9O'></q></dir></style></legend>

    <bdo id='P7r9O'></bdo><ul id='P7r9O'></ul>

  • <i id='P7r9O'><tr id='P7r9O'><dt id='P7r9O'><q id='P7r9O'><span id='P7r9O'><b id='P7r9O'><form id='P7r9O'><ins id='P7r9O'></ins><ul id='P7r9O'></ul><sub id='P7r9O'></sub></form><legend id='P7r9O'></legend><bdo id='P7r9O'><pre id='P7r9O'><center id='P7r9O'></center></pre></bdo></b><th id='P7r9O'></th></span></q></dt></tr></i><div id='P7r9O'><tfoot id='P7r9O'></tfoot><dl id='P7r9O'><fieldset id='P7r9O'></fieldset></dl></div>

    1. <tfoot id='P7r9O'></tfoot>

        <small id='P7r9O'></small><noframes id='P7r9O'>

        Python 中的 Pillow 不允许我打开图像(“超出限制")

        Pillow in Python won#39;t let me open image (quot;exceeds limitquot;)(Python 中的 Pillow 不允许我打开图像(“超出限制))

          <legend id='BBkL5'><style id='BBkL5'><dir id='BBkL5'><q id='BBkL5'></q></dir></style></legend>

            <bdo id='BBkL5'></bdo><ul id='BBkL5'></ul>
            <i id='BBkL5'><tr id='BBkL5'><dt id='BBkL5'><q id='BBkL5'><span id='BBkL5'><b id='BBkL5'><form id='BBkL5'><ins id='BBkL5'></ins><ul id='BBkL5'></ul><sub id='BBkL5'></sub></form><legend id='BBkL5'></legend><bdo id='BBkL5'><pre id='BBkL5'><center id='BBkL5'></center></pre></bdo></b><th id='BBkL5'></th></span></q></dt></tr></i><div id='BBkL5'><tfoot id='BBkL5'></tfoot><dl id='BBkL5'><fieldset id='BBkL5'></fieldset></dl></div>

            <small id='BBkL5'></small><noframes id='BBkL5'>

            1. <tfoot id='BBkL5'></tfoot>

                    <tbody id='BBkL5'></tbody>
                  本文介绍了Python 中的 Pillow 不允许我打开图像(“超出限制")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  只是在 Python 中对一些天气数据进行模拟时遇到了一些问题.数据以 .tif 格式提供,因此我使用以下代码尝试打开图像以将数据提取到 numpy 数组中.

                  Just having some problems running a simulation on some weather data in Python. The data was supplied in a .tif format, so I used the following code to try to open the image to extract the data into a numpy array.

                  from PIL import Image
                  
                  im = Image.open('jan.tif')
                  

                  但是当我运行这段代码时,我得到了以下错误:

                  But when I run this code I get the following error:

                  PIL.Image.DecompressionBombError: Image size (933120000 pixels) exceeds limit of 178956970 pixels, could be decompression bomb DOS attack.
                  

                  看起来这只是针对此类攻击的某种保护,但我实际上需要数据,而且它来自信誉良好的来源.有没有办法解决这个问题,还是我必须寻找另一种方法来做到这一点?

                  It looks like this is just some kind of protection against this type of attack, but I actually need the data and it is from a reputable source. Is there any way to get around this or do I have to look for another way to do this?

                  推荐答案

                  试试

                  PIL.Image.MAX_IMAGE_PIXELS = 933120000
                  

                  这样的事怎么查?

                  import PIL
                  print(PIL.__file__)  # prints, e. g., /usr/lib/python3/dist-packages/PIL/__init__.py
                  

                  然后

                  cd /usr/lib/python3/dist-packages/PIL
                  grep -r -A 2 'exceeds limit' .
                  

                  打印

                  ./Image.py:            "Image size (%d pixels) exceeds limit of %d pixels, "
                  ./Image.py-            "could be decompression bomb DOS attack." %
                  ./Image.py-            (pixels, MAX_IMAGE_PIXELS),
                  

                  然后

                  grep -r MAX_IMAGE_PIXELS .
                  

                  打印

                  ./Image.py:MAX_IMAGE_PIXELS = int(1024 * 1024 * 1024 / 4 / 3)
                  ./Image.py:    if MAX_IMAGE_PIXELS is None:
                  ./Image.py:    if pixels > MAX_IMAGE_PIXELS:
                  ./Image.py:            (pixels, MAX_IMAGE_PIXELS),
                  

                  然后

                  python3
                  import PIL.Image
                  PIL.Image.MAX_IMAGE_PIXELS = 933120000
                  

                  无怨无悔地工作并解决您的问题.

                  Works without complaint and fixes your issue.

                  这篇关于Python 中的 Pillow 不允许我打开图像(“超出限制")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Adding config modes to Plotly.Py offline - modebar(将配置模式添加到 Plotly.Py 离线 - 模式栏)
                  Plotly: How to style a plotly figure so that it doesn#39;t display gaps for missing dates?(Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙?)
                  python save plotly plot to local file and insert into html(python将绘图保存到本地文件并插入到html中)
                  Plotly: What color cycle does plotly express follow?(情节:情节表达遵循什么颜色循环?)
                  How to save plotly express plot into a html or static image file?(如何将情节表达图保存到 html 或静态图像文件中?)
                  Plotly: How to make a line plot from a pandas dataframe with a long or wide format?(Plotly:如何使用长格式或宽格式的 pandas 数据框制作线图?)

                      <bdo id='AyHW1'></bdo><ul id='AyHW1'></ul>
                        <i id='AyHW1'><tr id='AyHW1'><dt id='AyHW1'><q id='AyHW1'><span id='AyHW1'><b id='AyHW1'><form id='AyHW1'><ins id='AyHW1'></ins><ul id='AyHW1'></ul><sub id='AyHW1'></sub></form><legend id='AyHW1'></legend><bdo id='AyHW1'><pre id='AyHW1'><center id='AyHW1'></center></pre></bdo></b><th id='AyHW1'></th></span></q></dt></tr></i><div id='AyHW1'><tfoot id='AyHW1'></tfoot><dl id='AyHW1'><fieldset id='AyHW1'></fieldset></dl></div>

                        <legend id='AyHW1'><style id='AyHW1'><dir id='AyHW1'><q id='AyHW1'></q></dir></style></legend>

                        <small id='AyHW1'></small><noframes id='AyHW1'>

                        1. <tfoot id='AyHW1'></tfoot>

                              <tbody id='AyHW1'></tbody>