V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
liuxu
V2EX  ›  Python

怎么用 Python 将 pdf, doc 等转换成 jpg

  •  
  •   liuxu ·
    liuquanhao · 2015-08-07 09:38:39 +08:00 · 7698 次点击
    这是一个创建于 3187 天前的主题,其中的信息可能已经有所发展或是发生改变。
    查看的python-uno和imagemagick实例,都只是转换了文档第一页,怎么把全部页面转换成jpg呢?
    3 条回复    2015-08-07 16:41:47 +08:00
    eriale
        2
    eriale  
       2015-08-07 10:01:34 +08:00   ❤️ 1
    我是先把doc转换成pdf,然后再转jpg。
    你可以用Wand(http://docs.wand-py.org/en/0.4.1/)来转:
    from wand.image import Image

    with Image(filename='filename.pdf') as pdf:
    with pdf.convert('jpeg') as image:
    image.save(filename='result.jpeg')
    gully
        3
    gully  
       2015-08-07 16:41:47 +08:00
    使用过好几个, 最靠谱的是基于 mupdf 的 Python 绑定: https://github.com/rk700/PyMuPDF

    demo: https://github.com/rk700/PyMuPDF/blob/master/demo/demo.py
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1336 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 17:28 · PVG 01:28 · LAX 10:28 · JFK 13:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.