I'm trying to convert, from the command line, .png files of screenshots created by scrot to pdf files. I can successfully do this within shotwell, but I'd like to do it from the command line. For some reason, the command

convert file.png file.pdf

does a conversion, but it's not a literal one (and wont print properly)

For comparison purposes, I've posted on the web the output from convert


and the output from shotwell.


As you can see, the file convert.pdf is much much lower resolution, larger font, and most importantly, doesn't print properly using the standard lpr command.

Are the any off-the-shelf, easily installable, png to pdf conversion programs that would do a better job than convert? Or alternatively are there options to convert that I could use that would result in an exact conversion? There are a billion flags for convert, but I really don't know where to start.

Thanks for any help!

  • I believe GIMP lets you do this. Import the image and then export it to PDF. – TheWanderer Oct 6 '15 at 3:39
  • Please edit your question and give us a link to the pdf or, at least, take a screenshot of it so we can see the difference. Your command works perfectly on my machine so I'm not sure what you need. What do you mean by "not a literal" conversion? – terdon Oct 6 '15 at 10:34
  • I've posted on the web the output from convert and the output from shotwell. The latter is what I was calling a "literal" conversion, in the sense that it looks indistinguishable from the original png file. I'd like to duplicate that kind of output using command-line command rather than a GUI. Thanks! – Leo Simon Oct 7 '15 at 4:19
  • You can use -density option of convert to get better resolution. – user43326 Aug 16 '18 at 6:55

I use the Phatch. You will have to create the actionlist with the graphical user interface (gui), and later invoke it from the command line.


sudo apt-get install phatch

Phatch is not only about converting from one format to another, but you can also batch crop, rotate, etc. After install select the program from the dash or type


into the command line. Now the gui will open. Click on the green cross and search for the "Save" command to add it to the actionlist. Define type as "pdf" and an output folder (and other parameters if you want to). Default output folder is ~/desktop/phatch. If the program can't find the indicated folder during the convert action, it will create it automatically. Now press Ctrl+Shift+S and save the actionlist giving it a name like "convert2pdf". Default path where actionlists are stored is ~/.local/share/phatch/actionlists. I recommend to choose your home folder for now. Now you have defined an actionlist which converts to pdf.

You have to do this previous step only once. From now on you can invoke the actionlist every time you need from the terminal in the following way:

phatch convert2pdf.phatch ~/folder/to/convert

Everything inside the ~/folder/to/convert will be converted to pdf and put into the output folder on your desktop. The original files won't be deleted.

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.