【问题标题】:How do I use hdfs file with Wand for Image conversion using Pyspark - Hadoop HDP 2.6.6如何使用带有 Wand 的 hdfs 文件使用 Pyspark 进行图像转换 - Hadoop HDP 2.6.6
【发布时间】:2019-04-23 16:26:23
【问题描述】:

我正在尝试将 pdf 文件转换为 Image,然后使用 pytesseract 对文件进行 ocr。我能够在 linux 本地路径中存在但不使用 hdfs 路径的文件上成功完成此操作。

    from wand.image import Image as wi

       >>> wi(filename = 'hdfs://boboda02.boobo.com:8020/bda/clamsops/raw/personal_brella_test/09_29_2015_090902.pdf',resolution = 300)

Traceback (most recent call last):

File "<stdin>", line 1, in <module>

File "/home/sam/my_env_1/lib/python2.7/site-packages/Wand-0.4.2-py2.7.egg/wand/image.py", line 2534, in __init__

File "/home/sam/my_env_1/lib/python2.7/site-packages/Wand-0.4.2-py2.7.egg/wand/image.py", line 2601, in read

File "/home/sam/my_env_1/lib/python2.7/site-packages/Wand-0.4.2-py2.7.egg/wand/resource.py", line 222, in raise_exception

wand.exceptions.MissingDelegateError: no decode delegate for this image format `//boboDA02.boobo.COM' @ error/constitute.c/ReadImage/501

【问题讨论】:

    标签: hadoop pdf image-processing pyspark wand


    【解决方案1】:

    您需要为hdfs 委托创建说明。

    我不熟悉 hadoop,但是 documentation 在本地复制文件似乎很简单。

    fs get --from <source> --to <local>
    

    创建一个名为 delegates.xml 的简单 XML 文件,其内容如下...

    <delegatemap>
      <delegate decode="hdfs" command="&quot;fs&quot; get --from &quot;hdfs:%M&quot; --to &quot;%o&quot;"/>
    </delegatemap>
    

    请参阅Resources 文档以了解 ImageMagick 如何加载委托文件,以及哪个选项适用于您的环境。您也可以询问 ImageMagick 的 identify 实用程序系统路径的位置。

    identify -list configure | grep SHARE_PATH
    

    如果在 SHARE_PATH 位置没有 delegates.xml 文件,则将新创建的 XML 文件复制到该位置。否则,如果该文件存在,您应该编辑该文件以在现有的&lt;delegatemap&gt; 中包含&lt;delegate 行。

    如果您没有管理员权限,或者系统是通过包管理器管理的,请探索适用于您的应用程序的其他选项。如$HOME/.config/ImageMagick/,或应用程序目录。请参阅上面链接的文档。

    您可以通过运行以下命令来验证 HDFS 的委派是否已正确映射。

    identify -list delegate | grep hdfs
    

    然后使用convert 实用程序对其进行测试。

    convert hdfs://boboda02.boobo.com:8020/bda/clamsops/raw/personal_brella_test/09_29_2015_090902.pdf output_%04d.jpg
    

    Wand 现在应该了解 hdfs 协议了。

    【讨论】:

      猜你喜欢
      • 2021-07-19
      • 1970-01-01
      • 2020-02-09
      • 2013-04-15
      • 1970-01-01
      • 2014-02-23
      • 2022-01-13
      • 2021-04-20
      • 2014-02-06
      相关资源
      最近更新 更多