linuxpdfthumbnailsghostscript

Prevent ghost script from auto rotating thumbnail


I'm using ghostscript (gs) to create thumbnail of first page. The problem I'm facing is that sometimes it auto rotates the thumbnail. Here's the command I'm using

gs -o thumb.jpeg -sDEVICE=jpeg -dLastPage=1 -dJPEGQ=100 -dPDFFitPage -g504x318 file.pdf

Is there any way to prevent gs from auto rotating on certain pdf files


Solution

  • As @KJ mention to make sure the thumbnail does not rotate. First make a square thumbnail like this

    gs -o thumb.jpeg -sDEVICE=jpeg -dLastPage=1 -dJPEGQ=100 -dPDFFitPage -g504x504 file.pdf
    

    than crop out the thumbnail to ideal size using another tool like sharp (for nodejs)

    await sharp("thumb.jpeg")
           .extract({width: 504, height: 314, top: 0, left: 0});