Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

idelovski

macrumors regular
Original poster
Sep 11, 2008
235
0
Hi,

just observed something strange so I wonder if anyone can clarify few things to me.

I wanted to save some bytes and have my pdf files smaller by resizing images. To my surprise, when I work with "online" images the resulting pdf file gets even bigger. When I work with camera images I get expected results and resulting pdf file is indeed smaller.

I start my pdf with UIGraphicsBeginPDFContextToData(), then I draw text or images to it and close it with UIGraphicsEndPDFContext(). Images are drawn with simple -drawInRect:.

In order to preserve some space, I scaled down images if they are too big. So I have some threshold value and if an image is bigger than that it gets resized. I looked at the whole process in debugger and all works as expected. I can see big images getting smaller if necessary, but resulting pdf data baffles me.

When I work with an image found on internet, when I save original JPEG in Safari and then move it from the Album in iOS simulator/device to my application these pictures when scaled down produce bigger pdf documents. Property length of resulting NSData object is bigger as observed in debugger. The file saved to disk is bigger too.

On the other hand, when I do all that with images taken with the camera, pdf data created with scaled down images is actually smaller (compared to pdf document created with original images).

Does anyone know what is going on with images drawn to pdf context? Are they compressed in the document? Are images that were converted from jpg easier to compress back compared to fuzzy camera images?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.