For the Indian "e-visa" application, the consulate wanted photos to be:
- uploaded as a pdf
- the pdf needed to be smaller than 300KB in size
More recently, they have started accepting jpg/png as well but since I had to do all this research to figure this stuff out, I might as well document it all here in case I ever need it in the future again.
Note: To get the photos (usually jpg/png) from the phone into the laptop see my earlier blog entry
The conversion is unfortunately not a 1-liner but a 2-liner:
convert scan.jpg scan.pdf # turn a jpeg into pdf
ps2pdf scan.pdf submit_scan.pdf # reduce size below 300 KB
The ps2pdf
can be run multiple times and it appears to reduce the size
each time around (probably some lossy compression is going on, I guess).
All of this is run on Linux and if those binaries are not available by default, they may be part of two additional packages which you may need to install:
- Imagemagick
- Ghostscript
If you are on Ubuntu it is just an apt-get
away:
sudo apt-get install -y imagemagick ghostscript
I was using these versions: ghostscript_9.26 and imagemagick_6.8.9
For other distros, you are on your own - on Nix for example, I assume this might "just work" (or not, YMMV):
nix-shell -p imagemagick ghostscript