hadoophdp2.6.6

g6ll5ycj  于 2021-05-29  发布在  Hadoop
关注(0)|答案(1)|浏览(255)

我正在尝试将pdf文件转换为图像,然后使用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
btxsgosb

btxsgosb1#

您需要为 hdfs 代表团。
我不熟悉hadoop,但是本地复制文件的文档似乎很简单。

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

创建一个名为 delegates.xml 包含以下内容。。。

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

请参阅参考资料文档,了解imagemagick如何加载委派文件,以及哪个选项适用于您的环境。你也可以问imagemagick的 identify 系统路径所在的实用程序。

identify -list configure | grep SHARE_PATH

如果没有 delegates.xml 文件,然后将新创建的xml文件复制到该位置。否则,如果该文件存在,则应编辑该文件以包含 <delegate 现有管道内的管线 <delegatemap> .
如果您没有管理员权限,或者系统是通过包管理器管理的,请探索适用于您的应用程序的其他选项。就像 $HOME/.config/ImageMagick/ ,或应用程序目录。参考上面链接的文档。
您可以通过运行以下命令来验证hdfs的委托是否已正确Map。

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协议了。

相关问题