简体   繁体   English

Imagemagick将多个图像转换为pdf大小

[英]Imagemagick convert multiple images to pdf size

For a project I am running ImageMagick to convert several images (all of the same size 960x570) into a single PDF. 对于一个项目,我运行ImageMagick将几个图像(所有相同大小960x570)转换为单个PDF。

The command I'm running is: 我正在运行的命令是:

convert *.jpg pdf/export.pdf

Since the images are all the same size I expect each PDF page to be equal in size but this is not the case as you can see in the screenshot below: 由于图像大小相同,我希望每个PDF页面的大小相同,但情况并非如此,您可以在下面的屏幕截图中看到:

示例截图

This is bit annoying since I don't know how I can force the size of each PDF page to be the same. 这有点烦人,因为我不知道如何强制每个PDF页面的大小相同。

I tested the PDF on both an android device, ubuntu pdf reader and adobe reader and they all show the different sizes. 我在Android设备,ubuntu pdf阅读器和adobe阅读器上测试了PDF,它们都显示了不同的大小。

Thanks for helping! 谢谢你的帮助!

EDIT1: After testing out a few more things as suggested by Marc B and Basti I managed to put the same size on the JPG (uploaded) images. 编辑1:在测试了Marc B和Basti建议的更多东西后,我设法在JPG(上传)图像上放置相同的尺寸。

The problem still persists with the images that are generated using webkit2png (Python script that converts a webpage/html file to an image). 使用webkit2png(将网页/ html文件转换为图像的Python脚本)生成的图像仍然存在问题。 After trying (almost?) everything in the convert command I can't get these generated images to shop up properly in the PDF as you can see below: 在尝试(几乎?)转换命令中的所有内容后,我无法在PDF中正确地购买这些生成的图像,如下所示:

在此输入图像描述

Any help would be much appreciated! 任何帮助将非常感激!

I found the solution: 我找到了解决方案:

I needed to add the following options to convert the image saved from webkit2png: 我需要添加以下选项来转换从webkit2png保存的图像:

-density 960x570 -units PixelsPerInch

I hope this helps other people out too in the future ;) 我希望将来能帮助其他人;)

After a few seconds of using google, I found this: 使用谷歌几秒钟后,我发现了这个:

-size <geometry> width and height of image

Example given by them: 他们给出的例子:

$ convert -size 320x85 canvas:none -font Bookman-DemiItalic -pointsize 72 \ 
-draw "text 25,60 'Magick'" -channel RGBA -blur 0x6 -fill darkred -stroke magenta \ 
-draw "text 20,55 'Magick'" fuzzy-magick.png

http://www.imagemagick.org/script/convert.php http://www.imagemagick.org/script/convert.php

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

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