It occurred to me that there must be a simpler way - so any suggestions?
You're right, there is! Try this:
sudo apt-get install imagemagick
cd ~/rare-book-images
convert "*.jpg" rare-book.pdf
Note: depending on what shell you're using "*.jpg" might not work as expected. Try omitting the quotes and seeing if that gets you the results you expect.
from reportlab.platypus import SimpleDocTemplate, Image
from reportlab.lib.pagesizes import letter
from glob import glob
doc = SimpleDocTemplate('image-collection.pdf', pagesize=letter)
parts = [Image(filename) for filename in glob('*.jpg')]
doc.build(parts)
If you're interested in a Python solution, you can use the ReportLab library. For example:
from reportlab.platypus import SimpleDocTemplate, Image
from reportlab.lib.pagesizes import letter
from glob import glob
doc = SimpleDocTemplate('image-collection.pdf', pagesize=letter)
parts = [Image(filename) for filename in glob('*.jpg')]
doc.build(parts)
This will take all the jpg files in your current directory and produce a file called "image-collection.pdf".
我想知道您是否可以使用 for 循环来完成此操作,其中包含 \includegraphics 命令,并在 LaTeX 文件内添加一些适当的漂亮标准图像文件命名等。这可能具有允许标题页等和页码编号等的优点。 (我不确定其他解决方案是否可以做到这一点,而且我懒得去检查。我只是在这里大声思考,真的)
I wonder if you could just do it with a for loop with a \includegraphics command inside and some suitably nifty standard image file naming and so on inside a LaTeX file. This might have the advantage of allowing title pages etc and page numbering and so on. (I'm not sure either of the other solutions do this and I can't be bothered to check. I'm just pondering out loud here, really)
发布评论
评论(3)
你说得对,有!试试这个:
注意:根据您使用的 shell,“*.jpg”可能无法按预期工作。尝试省略引号,看看是否会得到您期望的结果。
You're right, there is! Try this:
Note: depending on what shell you're using "*.jpg" might not work as expected. Try omitting the quotes and seeing if that gets you the results you expect.
如果您对 Python 解决方案感兴趣,可以使用 ReportLab 库。例如:
这将获取当前目录中的所有 jpg 文件并生成一个名为“image-collection.pdf”的文件。
If you're interested in a Python solution, you can use the ReportLab library. For example:
This will take all the jpg files in your current directory and produce a file called "image-collection.pdf".
我想知道您是否可以使用
for
循环来完成此操作,其中包含\includegraphics
命令,并在 LaTeX 文件内添加一些适当的漂亮标准图像文件命名等。这可能具有允许标题页等和页码编号等的优点。 (我不确定其他解决方案是否可以做到这一点,而且我懒得去检查。我只是在这里大声思考,真的)I wonder if you could just do it with a
for
loop with a\includegraphics
command inside and some suitably nifty standard image file naming and so on inside a LaTeX file. This might have the advantage of allowing title pages etc and page numbering and so on. (I'm not sure either of the other solutions do this and I can't be bothered to check. I'm just pondering out loud here, really)