ImageMagickを使用して画像をPDFに変換するときのPDFタグの設定

ImageMagickを使用して画像をPDFに変換するときのPDFタグの設定

画像を単一のPDFファイルに変換するユーティリティを使用していますconvert

$ convert "document-*.tiff" -compress jpeg -quality 60 "output.pdf"

生成された文書には、次のタグが設定されています。

Title:          output
Producer:       file:///usr/share/doc/imagemagick-6-common/html/index.html
CreationDate:   Fri May 21 19:12:24 2021 +04
ModDate:        Fri May 21 19:12:24 2021 +04
Tagged:         no
UserProperties: no
Suspects:       no
Form:           none
JavaScript:     no
Pages:          1
Encrypted:      no
Page size:      419.52 x 595.2 pts
Page rot:       0
File size:      226476 bytes
Optimized:      no
PDF version:    1.3

タイトル、生産者などのタグのデフォルト値を上書きできますか?

ベストアンサー1

できます。次のコマンドを使用してイメージレジストリを変更する必要があります。-define

たとえば、

$ magick -compress jpeg -quality 60 -define pdf:Producer="Stackoverflow" -define pdf:Title="Change tags" "*tiff" "output.pdf"

$ pdfinfo output.pdf 
Title:          Change tags
Author:         https://imagemagick.org
Producer:       Stackoverflow
CreationDate:   Fri May 21 10:49:33 2021 -03
ModDate:        Fri May 21 10:49:33 2021 -03
Tagged:         no
[...]

しかし、これには少なくともバージョン7が必要です(それで私はコメントで要求しました)。そうでない場合は、自分で作成できます。とても簡単です。

テストしたばかりのDebian 10では、次のものが必要です。

$ sudo apt-get install build-essential
$ cd /some/path
$ wget https://www.imagemagick.org/download/ImageMagick.tar.gz
$ cd ImageMagick-7.0.11-13 # that's today's, the version might change
$ ./configure
$ make

システム全体にインストールを実行する必要はありません。次のコマンドを実行します。

$ /some/path/ImageMagick-7.0.11-13/utilities/magick -compress jpeg -quality 60 -define pdf:Producer="Stackoverflow" -define pdf:Title="Change tags" "*tiff" "output.pdf"

おすすめ記事