Imagemagick convert 将png和x27相结合;将其转换为PDF格式,而无需重新命名
我正在使用ImageMagick的Imagemagick convert 将png和x27相结合;将其转换为PDF格式,而无需重新命名,imagemagick-convert,Imagemagick Convert,我正在使用ImageMagick的convert将6个PNG文件合并成PDF: Bytes File name ----- --------- 44927 002.png 43507 003.png 71375 004.png 56448 005.png 61696 006.png 57694 007.png # Both generate a 533,378 byte PDF convert 00?.png OutputFile.pdf convert 00?
convert
将6个PNG文件合并成PDF:
Bytes File name
----- ---------
44927 002.png
43507 003.png
71375 004.png
56448 005.png
61696 006.png
57694 007.png
# Both generate a 533,378 byte PDF
convert 00?.png OutputFile.pdf
convert 00?.png -density 200x200 OutputFile.pdf
这些图像是来自平板扫描仪的200 DPI黑白扫描。PNG文件的总大小为335647 KB,但生成的OutputFile.pdf
为533378 KB
这种尺寸膨胀是因为重新光栅化吗?
如何指定转换以保持现有像素?
如果有必要的话,我将在Windows 10 64位(
cygcheck-p convert | grep-I ImageMagick
)上使用Cygwin的ImageMagick 7.0.10.27-1。下面的pdfimages
输出有一些默认压缩(在比率
列下)。我回忆起转换的深度。depth
选项没有减少每像素的位数。从下面的测试中可以看出,深度
与单色
组合使用时也不会出现这种情况。此外,单色
导致DPI从200变为508或509,这很奇怪
文件大小膨胀的一个可能原因是使用8位/像素。从上面链接的convert
之前的测试来看,压缩似乎挤出了每像素不需要的8位所浪费的空间。然而,从PDF文件大小来看,如果这是真的,那么它并不能真正弥补所有文件大小的膨胀
# 1st default, monochrome, 200dpi, depth 1, and combinations
convert 00?.png default.pdf
convert -monochrome 00?.png mono.pdf
convert -monochrome 00?.png -density 200x200 mono200.pdf
convert -depth 1 00?.png depth1.pdf
convert -monochrome -depth 1 00?.png monoDepth1.pdf
ls -l *.pdf
510362 default.pdf
510350 mono.pdf
510362 mono200.pdf
510362 depth1.pdf
510374 monoDepth1.pdf
for file in *.pdf ; do echo ' ' ; echo $file: ; pdfimages -list $file ; done
default.pdf:
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 1700 2167 gray 1 8 image no 8 0 200 200 70.1K 1.9%
2 1 image 1700 2145 gray 1 8 image no 22 0 200 200 67.8K 1.9%
3 2 image 1700 2139 gray 1 8 image no 36 0 200 200 97.8K 2.8%
4 3 image 1700 2156 gray 1 8 image no 50 0 200 200 80.2K 2.2%
5 4 image 1700 2156 gray 1 8 image no 64 0 200 200 89.9K 2.5%
6 5 image 1700 2150 gray 1 8 image no 78 0 200 200 85.2K 2.4%
mono.pdf:
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 1700 2167 gray 1 8 image no 8 0 200 200 70.1K 1.9%
2 1 image 1700 2145 gray 1 8 image no 22 0 200 200 67.8K 1.9%
3 2 image 1700 2139 gray 1 8 image no 36 0 200 200 97.8K 2.8%
4 3 image 1700 2156 gray 1 8 image no 50 0 200 200 80.2K 2.2%
5 4 image 1700 2156 gray 1 8 image no 64 0 200 200 89.9K 2.5%
6 5 image 1700 2150 gray 1 8 image no 78 0 200 200 85.2K 2.4%
mono200.pdf:
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 1700 2167 gray 1 8 image no 8 0 508 508 70.1K 1.9%
2 1 image 1700 2145 gray 1 8 image no 22 0 508 508 67.8K 1.9%
3 2 image 1700 2139 gray 1 8 image no 36 0 508 509 97.8K 2.8%
4 3 image 1700 2156 gray 1 8 image no 50 0 508 508 80.2K 2.2%
5 4 image 1700 2156 gray 1 8 image no 64 0 508 508 89.9K 2.5%
6 5 image 1700 2150 gray 1 8 image no 78 0 508 509 85.2K 2.4%
depth1.pdf:
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 1700 2167 gray 1 8 image no 8 0 200 200 70.1K 1.9%
2 1 image 1700 2145 gray 1 8 image no 22 0 200 200 67.8K 1.9%
3 2 image 1700 2139 gray 1 8 image no 36 0 200 200 97.8K 2.8%
4 3 image 1700 2156 gray 1 8 image no 50 0 200 200 80.2K 2.2%
5 4 image 1700 2156 gray 1 8 image no 64 0 200 200 89.9K 2.5%
6 5 image 1700 2150 gray 1 8 image no 78 0 200 200 85.2K 2.4%
monoDepth1.pdf:
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 1700 2167 gray 1 8 image no 8 0 200 200 70.1K 1.9%
2 1 image 1700 2145 gray 1 8 image no 22 0 200 200 67.8K 1.9%
3 2 image 1700 2139 gray 1 8 image no 36 0 200 200 97.8K 2.8%
4 3 image 1700 2156 gray 1 8 image no 50 0 200 200 80.2K 2.2%
5 4 image 1700 2156 gray 1 8 image no 64 0 200 200 89.9K 2.5%
6 5 image 1700 2150 gray 1 8 image no 78 0 200 200 85.2K 2.4%
pdfimages
输出显示下面有一些默认压缩(在ratio
列下)。我回忆起转换的深度。depth
选项没有减少每像素的位数。从下面的测试中可以看出,深度
与单色
组合使用时也不会出现这种情况。此外,单色
导致DPI从200变为508或509,这很奇怪
文件大小膨胀的一个可能原因是使用8位/像素。从上面链接的convert
之前的测试来看,压缩似乎挤出了每像素不需要的8位所浪费的空间。然而,从PDF文件大小来看,如果这是真的,那么它并不能真正弥补所有文件大小的膨胀
# 1st default, monochrome, 200dpi, depth 1, and combinations
convert 00?.png default.pdf
convert -monochrome 00?.png mono.pdf
convert -monochrome 00?.png -density 200x200 mono200.pdf
convert -depth 1 00?.png depth1.pdf
convert -monochrome -depth 1 00?.png monoDepth1.pdf
ls -l *.pdf
510362 default.pdf
510350 mono.pdf
510362 mono200.pdf
510362 depth1.pdf
510374 monoDepth1.pdf
for file in *.pdf ; do echo ' ' ; echo $file: ; pdfimages -list $file ; done
default.pdf:
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 1700 2167 gray 1 8 image no 8 0 200 200 70.1K 1.9%
2 1 image 1700 2145 gray 1 8 image no 22 0 200 200 67.8K 1.9%
3 2 image 1700 2139 gray 1 8 image no 36 0 200 200 97.8K 2.8%
4 3 image 1700 2156 gray 1 8 image no 50 0 200 200 80.2K 2.2%
5 4 image 1700 2156 gray 1 8 image no 64 0 200 200 89.9K 2.5%
6 5 image 1700 2150 gray 1 8 image no 78 0 200 200 85.2K 2.4%
mono.pdf:
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 1700 2167 gray 1 8 image no 8 0 200 200 70.1K 1.9%
2 1 image 1700 2145 gray 1 8 image no 22 0 200 200 67.8K 1.9%
3 2 image 1700 2139 gray 1 8 image no 36 0 200 200 97.8K 2.8%
4 3 image 1700 2156 gray 1 8 image no 50 0 200 200 80.2K 2.2%
5 4 image 1700 2156 gray 1 8 image no 64 0 200 200 89.9K 2.5%
6 5 image 1700 2150 gray 1 8 image no 78 0 200 200 85.2K 2.4%
mono200.pdf:
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 1700 2167 gray 1 8 image no 8 0 508 508 70.1K 1.9%
2 1 image 1700 2145 gray 1 8 image no 22 0 508 508 67.8K 1.9%
3 2 image 1700 2139 gray 1 8 image no 36 0 508 509 97.8K 2.8%
4 3 image 1700 2156 gray 1 8 image no 50 0 508 508 80.2K 2.2%
5 4 image 1700 2156 gray 1 8 image no 64 0 508 508 89.9K 2.5%
6 5 image 1700 2150 gray 1 8 image no 78 0 508 509 85.2K 2.4%
depth1.pdf:
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 1700 2167 gray 1 8 image no 8 0 200 200 70.1K 1.9%
2 1 image 1700 2145 gray 1 8 image no 22 0 200 200 67.8K 1.9%
3 2 image 1700 2139 gray 1 8 image no 36 0 200 200 97.8K 2.8%
4 3 image 1700 2156 gray 1 8 image no 50 0 200 200 80.2K 2.2%
5 4 image 1700 2156 gray 1 8 image no 64 0 200 200 89.9K 2.5%
6 5 image 1700 2150 gray 1 8 image no 78 0 200 200 85.2K 2.4%
monoDepth1.pdf:
page num type width height color comp bpc enc interp object ID x-ppi y-ppi size ratio
--------------------------------------------------------------------------------------------
1 0 image 1700 2167 gray 1 8 image no 8 0 200 200 70.1K 1.9%
2 1 image 1700 2145 gray 1 8 image no 22 0 200 200 67.8K 1.9%
3 2 image 1700 2139 gray 1 8 image no 36 0 200 200 97.8K 2.8%
4 3 image 1700 2156 gray 1 8 image no 50 0 200 200 80.2K 2.2%
5 4 image 1700 2156 gray 1 8 image no 64 0 200 200 89.9K 2.5%
6 5 image 1700 2150 gray 1 8 image no 78 0 200 200 85.2K 2.4%
PNG已经光栅化。但我怀疑PDF会将光栅图像作为原始数据(未格式化为PNG)保存在PDF vector shell中。我不知道如何告诉ImageMagick压缩它们。您可以使用其他工具将光栅图像转换为PDF文件谢谢,但似乎出现了默认压缩,只是不足以弥补每单色像素8位的不足。其他工具的研究需要时间,因此为了方便起见,我采用了convert
。我将采用大约2倍的文件大小。PNG已经光栅化。但我怀疑PDF会将光栅图像作为原始数据(未格式化为PNG)保存在PDF vector shell中。我不知道如何告诉ImageMagick压缩它们。您可以使用其他工具将光栅图像转换为PDF文件谢谢,但似乎出现了默认压缩,只是不足以弥补每单色像素8位的不足。其他工具的研究需要时间,因此为了方便起见,我采用了convert
。我将接受大约2倍的文件大小。