double0201 2010-09-11 21:05
浏览 67

如何在我的Linux服务器上创建PDF文件的缩略图/屏幕截图?

I want to create thumbnails out of PDF files to be able to display a short preview of the PDF file on a website.

I tried it by using ImageMagick. Unfortunately the results aren't very pleasing. The resulting images are very fuzzy.

Example Thumbnail (fuzzy):

Bildschirmfoto 2010-09-11 um 22.57.49.png

Original PDF: (see Comment)

Command: convert -thumbnail x800 k.pdf[0] test.png

Is my convert command misconfigured or do you know any better way achieving my goal?

  • 写回答

2条回答 默认 最新

  • du13932014807 2010-09-11 21:23
    关注

    Your original pdf is smaller than the thumbnail you're creating. Imagemagick scales the image to match the requested dimensions. Use the following parameters:

    convert -scale '800x800+0+0>' -colorspace rgb -strip in.pdf[0] out.png
    

    The trailing > in the scale parameter tells Imagemagick to not scale the image to larger than the original.

    Edit: Imagemagick uses Ghostscript to render PDF files. You can use Ghostscript directly if you need to set some parameters, like resolution to get a better image. Default resolution is 72 DPI which means that an A4 paper has size of 595 x 841 pixels. With 150 DPI you'll get twice the number of pixels. E.g.

    gs -q -dBATCH -dNOPAUSE -sDEVICE=pngalpha -dMAxBitmap=500000000 -dAlignToPixles=0 -dGridFitTT=0 -r150x150 -sOutputFile=out.png in.pdf
    

    The above command is almost identical to the one Imagemagick uses. Note the -r parameter which sets 150 DPI resolution. You can use ImageMagick to scale the resulting image to smaller size.

    Using a higher resolution will reduce fuzziness when you resize the image.

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料