我尝试将pdf转换为每页png文件并删除第4个Alpha通道。 ImageMagick表现得非常奇怪,因为除了一页之外,它正在正确地删除alpha。我的命令中有错误吗?
命令我执行:
convert -units PixelsPerInch -density 300 -alpha remove nips09_4.pdf nips09_4.png
结果:
$ identify -verbose nips09_4-2.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 2480x3508+0+0
Resolution: 118.11x118.11
Print size: 20.9974x29.7011
Units: PixelsPerCentimeter
Type: TrueColorAlpha
Endianess: Undefined
Colorspace: sRGB
Depth: 16-bit
Channel depth:
red: 16-bit
green: 16-bit
blue: 16-bit
alpha: 1-bit
$ identify -verbose nips09_4-1.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 2480x3508+0+0
Resolution: 118.11x118.11
Print size: 20.9974x29.7011
Units: PixelsPerCentimeter
Type: Palette
Endianess: Undefined
Colorspace: sRGB
Depth: 16-bit
Channel depth:
red: 16-bit
green: 16-bit
blue: 16-bit
重现:
cd ~/Downloads
wget http://papers.nips.cc/paper/3723-anomaly-detection-with-score-functions-based-on-nearest-neighbor-graphs.pdf
mv 3723-anomaly-detection-with-score-functions-based-on-nearest-neighbor-graphs.pdf nips09_4.pdf
convert -units PixelsPerInch -density 300 -alpha remove nips09_4.pdf nips09_4.png
答案 0 :(得分:3)
在加载PDF后尝试使用-alpha off,看看是否有帮助。像这样:
FormOpenerModel
我相信convert -density 300 some.pdf -alpha off nips%03d.png
会移除Alpha通道的效果,但实际上它仍然存在,但在图像中不透明,并且会被转移到您的-alpha remove
图像。
相比之下,PNG
实际上完全删除了频道,因此它不会显示在alpha off
图片中。