Linux Commands

How to View or Edit PDF/Image Metadata from Command Line – Linux

ISO (International Organization for Standardization) has maintained an open source for Portable Document Format or PDF as it is a widely used file format. One speciality is that you can exchange the PDF documents independent of software, hardware and operating systems being used. The general information about a PDF file is called its Metadata and we can inspect and edit it. This article is all about How to View or Edit PDF/Image Metadata from Command Line on Linux.

How to View or Edit PDF/Image Metadata from Command Line

You can view or edit the Metadata of your PDF and image file using the below mentioned methods:

How to View the Metadata of a PDF File Using exiftool Command

Step 1: You can install exiftool on your Linux system by executing the command mentioned below:

sudo apt install libimage-exiftool-perl

Step 2: Now you can view the metadata of any PDF file using the command format given below:

exiftool <file name>.pdf

For demonstration I have executed the command for file name example using the above format:

exiftool example.pdf

You can also use the command format given below to know the specific data of a PDF file:

exiftool -creator <file name>.pdf

For demonstration I have executed the command for file name example using the above format to know the name of creator of the file:

How to View the Metadata of a PDF File Using pdfinfo Command

You can view the metadata of a PDF file on Linux by using the command pdfinfo following the syntax given below:

pdfinfo <file-name>.pdf

Now to view the metadata of file name example using pdfinfo command execute the command mentioned below:

pdfinfo example.pdf

How to View the Metadata of a PDF File Using file Command

You can view the metadata of a PDF file on Linux by using the command file following the  syntax given below:

file <filename>.pdf

Now to view the metadata of file name example using file command execute the command mentioned below:

file example.pdf

How to Edit PDF Metadata Using exiftool Command

You can edit the metadata of any PDF file using the syntax given below which is used to edit the name of the file creator:

exiftool -<information-to-be-changed>="<desired-name>" <file-name>.pdf

For example, you if want to edit the name of the creator of the file you can execute the command given below using the above syntax:

exiftool -creator="linuxconfig" example.pdf

You can clear the metadata for a field by overwriting it with empty data, using the given below syntax.

exiftool -Subject= <file name>.pdf

For example, you can clear the metadata of file example by running the command given below:

exiftool -Subject= example.pdf

You can also clear the metadata for all fields in the PDF file, using the given below syntax:

exiftool -all= <file name>.pdf

For example, you can clear the metadata of file example by running the command given below:

exiftool -all= example.pdf

You can see there is a file named example in the Documents folder:

You can change the title of the file executing the command format given below:

exiftool -Title="This is the title" <file name>.pdf

For example, you can change the title of file example by running the command given below:

exiftool -Title="This is the title" example.pdf

In the above image you can see the file has been updated and you can see the title of the pdf file.

How to View Image Metadata using exiftool

You can also use the exiftool to View or Edit the Metadata of an image file. Follow the syntax given below to view the metadata of an image file:

exiftool <filename>.jpg

To demonstrate I have used the image named as Index to view its metadata using exiftool following the syntax of command given above:

exiftool index.jpg

How to Edit Image Metadata using exiftool

You can edit the tags of the image using the format given below:

exiftool -artist="<name>" <file name>.jpeg

For example, i changed the artist’s name of the image index using the command mentioned below:

exiftool -artist="Mark" index.jpeg

You can see the changed tag using the command given above for showing all the metadata of the image above. Similarity you can modify the all the parameters of the metadata of an image using the following syntax:

exiftool -<metadata parameter>="<modified data>" <image file>

Conclusion

This article provides you the proper guide on how you can view and edit the metadata of an image or pdf file using different command line tools. One of the best tools is exiftool as it provides you with the function of viewing as well as editing the metadata of a pdf file. Further you can use file and pdfinfo commands to view the metadata of files by using the guide mentioned above in the article.

About the author

Rafia Amjad

I have a degree in Electronics and love to write. My research and writing emphasize on the most recent innovations in gaming and technology.