The reason for the increase in file size is that your source JP2 files probably contain lossily-compressed image data, and that ImageMagick/GraphicsMagick by default uses lossless compression while writing output. This means that the PDF contains a lossless representation of your original (lossy) image data, which explains the increase in file size (which can be huge!).
I tested this myself (using ImageMagick rather than GraphicsMagick) with a 5 MB JP2 image, which I converted to PDF using:
This produced a 14 MB PDF.
You can force lossy compression by using IM's "-quality" switch, which is explained here:
http://studio.imagemagick.org/script/co ... hp#quality
As a test I used the following command line:
Code: Select all
convert test.jp2 -quality 75 testLossy.pdf
This resulted in a PDF of slightly under 3 MB.
Although this works, it's not an ideal solution, as it applies lossy compression to image data that were already lossily compressed in the first place, resulting in unnecessary loss of quality (as also pointed out by dingodog above). You'd really want IM to simply transcode the original image codestream, but it just doesn't support that.
However, if you're only using the PDFs as an access format and you plan to keep the original JP2 files it might be good enough (you may want to do some experimenting with the quality factor).
Some side notes:
- 1. In the JP2 to PDF conversion with ImageMagick/GraphicsMagick you will lose any resolution info that was in the original JP2 (this is because of limitations of the JasPer library which is used by IM/GM for encoding/decoding JPEG 2000 images)
- 2. I noticed that the conversion in IM resulted in a PDF 1.3 file. However, the 'JPXDecode' filter that is used for JPEG 2000 data in PDF is only supported from PDF 1.5 onward. Probably not a huge problem, but you might run into some issues when opening these files in older PDF viewers.
- 3. Also, be aware that some mobile devices are not yet supporting PDF documents with embedded JPEG 2000 image streams!
Hope this is useful.
Cheers,
Johan
---------
Johan van der Knijff
KB / National Library of the Netherlands