[英]Lossless rotation of PDF files with imagemagick
我想使用 CLI 工具旋轉名為08-file.pdf
的 351K PDF。 我試過imagemagick :
convert 08-file.pdf -rotate 90 08-file-rotated.pdf
但原始質量:
遭受嚴重退化:
我已經嘗試添加-density 300x300
參數,但結果是一個 2.5M 的文件,比原始文件大近一個數量級,這是一種巨大的浪費。
知道如何使用 imagemagick 無損旋轉 PDF 文件嗎?
11/我在使用 imagemagik/convert 轉換/更改 pdf 文件時總是有不好的結果(分辨率差或文件大)。 使用選項-compress -density -quality總是令人沮喪和浪費時間(但我不是專家)。
所以我會推薦pdftk (你可能需要通過 apt-get install 安裝它)
嘗試:
pdftk 08-file.pdf cat 1-endright output 08-file-rotated.pdf
對於舊版本的 pdftk (v<3) 旋轉僅由一個字母表示:N:0,E:90,S:180,W:270,L:-90,R:+90,D:+180。 相同的命令是:
pdftk 08-file.pdf cat 1-endR output 08-file-rotated.pdf
從本網站的另一篇文章中,我對語法進行了簡要說明
pdftk input.pdf cat 1-endsouth output output.pdf
# \_______/ \___/\___/ \________/
# input file range | output file
# direction
你也可以看到https://linux.die.net/man/1/pdftk
2020年編輯:
我找到了另一種等效的替代方法: qpdf ,更容易記住且功能更強大
參見QPDF 手冊
#Syntax (you can rotate only some pages of the document -- see the manual --
qpdf --rotate=[+|-]angle[:page-range]
# Example
qpdf in.pdf out.pdf --rotate=+180
請使用-compress lossless
選項:
convert -rotate 90 -compress lossless 08-file.pdf 08-file-rotated.pdf
從文檔: https : //www.imagemagick.org/script/command-line-options.php#compress
Lossless 是指無損 JPEG,只有在 JPEG 庫已被修補以支持它時才可用。
另一種選擇是使用以下命令:
jhead -cmd "jpegtran -progressive -perfect -rotate 270 &i > &o" Image-0001.jpeg
它將輸出寫入臨時文件,成功后將覆蓋原始文件:
Cmd:jpegtran -progressive -perfect -rotate 270 "Image-0001.jpeg" > "h1xQ6q"
修改:Image-0001.jpeg
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.