简体   繁体   English

如何使用Wand和Python打开多个图像

[英]How to open multiple images using Wand and Python

I'm trying to use imagemagick to take several JPGs and lay them out on a pdf 我正在尝试使用imagemagick来获取几个JPG并将它们放在pdf上

I'm at the beginning of the project and I do not understand how to open the multiple images and do this. 我正处于项目的开始阶段,我不明白如何打开多个图像并执行此操作。

My research indicated to me that this is possible on the command line by simply passing the convert() function multiple files. 我的研究表明,只需将convert()函数传递给多个文件,就可以在命令行中实现。 experience is telling me that this isn't how it's done with Wand, but I can't figure out how! 经验告诉我,这不是用魔杖完成的,但我无法弄清楚如何!

Any advice is appreciated! 任何建议表示赞赏!

  • my example code is below. 我的示例代码如下。
  • before you excute this code, insert the dir path. 在执行此代码之前,插入dir路径。

import os
from wand.image import Image
from wand.display import display

path = "____absolute_dir_path____ (ex. /home/kim/work/)"

dirList=os.listdir(path)
for fname in dirList:
    print fname
    with Image(filename=path+fname) as img:
        print img.size

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM