On 1/11/2010 4:16, Jason Berk wrote: > I created a PDF that has two images, created from .tiff files and the > resulting PDF is roughly 50K. I then converted the .tiff files to .png > and recreated the same PDF, which is now 70K. Yet, the file size of the > image itself decreased significantly when converting to PNG. > > Image1.png = 41.6K > Image1.tif = 113.9K > > Image2.png = 36.5K > Image2.tif = 139.5K > > Yet the PDF created using the PNG is 20K larger?!?! How did that > happen?
Take a look at table 10.2 in the second edition of "iText in Action". PNGs are handled by the class PngImage and (I quote) just like GIF images, iText decodes PNG images into raw images. These raw images are then compressed (using CCITT or zlib/flate depending on the nature of the image). TIFFs are handled using TiffImage. This class will (I quote) inspect the TIFF file and, depending on its parameters, it can return an ImgCCITT, an ImgRaw, or even a Jpeg instance. In other words: the compression method of the image inside the PDF depends on the source. The same image has a different size as a PNG (e.g. 41.6K) compared to its TIFF format (e.g. 113.9K) because a different compression method is used. For the same reason the PDFs are different in size, and incidentally, the PDF is smaller for the TIFF than for the PNG (maybe because the TIFF could be compressed as a JPG). -- This answer is provided by 1T3XT BVBA http://www.1t3xt.com/ - http://www.1t3xt.info ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ iText-questions mailing list iText-questions@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/itext-questions Many questions posted to this list can (and will) be answered with a reference to the iText book: http://www.itextpdf.com/book/ Please check the keywords list before you ask for examples: http://itextpdf.com/themes/keywords.php