2

I'm converting images to a single PDF-file using convert utility:

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

Resulting document has the following tags set up:

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

Is it possible to override default values for tags like Title and Producer?

8
  • 1
    Does it need to be done by imagemagick or are you also interested in solutions using another tool to change the tag in the generated pdf?
    – terdon
    May 21 at 11:54
  • @terdon If possible I would like to set tags during conversion, because as I understand from ExifTool documentation all subsequent modifications will be reversible and old versions of tags will stay in a PDF file.
    – anlar
    May 21 at 12:41
  • Anything you do will be reversible. That's just meta data and any editor that can handle PDF tags can change the values. Why is that a problem?
    – terdon
    May 21 at 12:46
  • Which version of imagemagick are you using? convert --version. The Producer tag was a bug, but has been fixed a couple of years ago. May 21 at 12:54
  • @terdon I meant that exiftool will only append new version of tags (not actually overriding old values, they will stay in file itself). So you can restore original values by deleting changes like $ exiftool -PDF-update:all= file.pdf.
    – anlar
    May 21 at 12:54
4

You can do it. You need to change the image registry with a -define

For example:

$ 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
[...]

But for that you need at least version 7 (that's why I asked you in the comments). If you don't have it, you can build it yourself, it is surprisingly simple.

For Debian 10, where I just tested, you need to:

$ 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

You don't need to do a system-wide install. Just run the command like this:

$ /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"
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.