Thursday, June 30, 2011

Converting Documents and Images to (Reasonably Sized) PDFs

On Linux this has been quite trivial for some time, but it's worth writing here that when one converts directly from JPG to PDF on a distribution such as Ubuntu that the file size may be undesirably large. In my use case I take pictures which my camera formats to JPG and then convert them to PDF to upload as proof of purchase and cost for certain tax reimbursements through an electronic system. I don't know why this is, but every time I convert directly from JPG the file sizes are too large: greater than the limit of 5MB. It would help if I changed the camera settings to take a slightly inferior picture, but I want the images to be clear for the reviewers.

I've found that first converting the JPGs to GIF (and in some cases slightly adjusting the percent quality of the GIF down a bit) is the key to getting my ultimately five or less MB PDF. Using Ubuntu I convert to GIF using "GIMP", installed to the system through a terminal with the following,

sudo apt-get install gimp
y

or if "aptitude" is installed

sudo aptitude install gimp
y
or if you like, through the software center (search for "GIMP")

by right-clicking the file, and choosing to open the program with "GIMP Image Editor" through the submenu that says "open with".

Once opened in GIMP, I select "File" and "Save As", choose image format "GIF", and make sure the file name terminates with ".gif" rather than the original format marker, choose the location I want the file to reside at, and then select "Save", which prompts another window, in this case exposing options to adjust, which I find nearly always to have a quality setting of 93, though I sometimes adjust to 89, and confirm the choices.

The last thing to do is to open the file in the default image viewer of the OS, and from there to select "File" and then "Print". In the print dialogue I choose "print to file", tell the system the location I want the result to reside at, the name of the file, and the file type (PDF).

One could simply open the JPG inside the default viewer and print, or inside GIMP and print, but the conversion from JPG to PDF leaves that slightly larger file than from GIF to PDF, even when adjustments of quality to a GIF to which the JPG is converted aren't made; the precise reason for the greater result in the one instance I don't know, and though a little unwieldy, this method seems to work quite well.

No comments: