Reduce the size of PDF file generated with Quartz2D - iphone

I'm looking for a way to reduce PDF size that I generate with Quartz. I'm drawing images with CGContextDrawImage in a CGPDFContext. What I'm afraid of is that the images are saved as Bitmap and not JPEG. Is there a way to check for that and a way to control that when writing the PDF?
I also tried reducing downscaling the image before writing it to the PDF context but I end up with an even larger file (although the page size in pixels is smaller).
Thanks!

There is no public API for setting CGPDFContext's image compression settings.

I'm not sur if you need to reduce PDF on the iPhone or if it's acceptable for you to reduce them on a PC/Mac.
On PC/Mac, Adobe Acrobat Pro (a commercial product not to be mistaken with Adobe Reader) has a PDF optimizer. Menu "Adavanced" > "PDF Optimizer...". This can downscale images, fonts, etc. As there is also a command-line interface (using AutoBatch). It isn't cheap but it's probably the best PDF compressor out there.

Related

why Evo PDF generates large size PDFs (HTML to PDF converter)?

I am using EVO pdf dll to convert aspx page having 3 chart control (with png format) in it to PDF, but it generates PDF having size of 400 kb.
IF RDLC is used to generate similar page then it generates page having size of 50 kb.But I dont have option of using RDLC.
Note that I tried JPEG compression setting also png chart images are of low dimensions (small size graphs) also the quality of images is not that great.
I coordinated with the evo pdf technical team but did not received proper response.
Your kind help highly appreciated.
You can also try to disable the font embedding with HtmlToPdfConverter.PdfDocumentOptions.EmbedFonts = false. This option can make the PDF document to not display the text properly if the font used in PDF is not installed on the computer where you display the PDF.
Another option to reduce the PDF document size is to set tmlToPdfConverter.PdfDocumentOptions.ImagesScalingEnabled = true. This can reduce the size and also the quality of large images displayed in HTML at a size much smaller than the actual physical size of the images.

iPad retina landing page size - 2MB

The landing page for an ipad retina (i.e 1536 x 2048) is about 2MB. Apple seems to mandate using a PNG for landing pages. Is it possible to reduce this file size? (my landing page is really simple already)
actually the byte size of image not only depends upon the resolution but also on bit depth.
e.g. 100x100 PNG 16bit/24bit
you can reduce the bit depth of the png if you feel like it is not affecting the image quality and if you do find the image quality becomes unacceptable on reducing bit depth then your image is not that simple.
you can also use colors/gradient instead of an image so that you can completely remove the image
you can also use the tiled image (if it suits you) and can keep a small image in the resources.
see... you have lots of choices my friend..!!
I am using ImageOptim to reduce all my images. Works great and fast. Just download, open and drag and drop a folder or all your images onto the interface.
http://imageoptim.com/
There is even a case study on how well this tool can be used to shrink your iOS-Apps:
http://imageoptim.com/tweetbot.html
Use Image Optimiser. You can optimise image online.

Use PNG or JPG for iPhone images downloaded from server

I realize that PNG is normally the web standard, but I might have a bit of a unique situation. I'm building an app that downloads lots of images from a server. The download needs to be as quick as possible, especially over 3G connections. I've been looking into the best compression for the images on the server. Ideally, every image I use can be quickly resized for the app using a drag and drop converter of some sort. When I convert one of the images to a PNG, the file size is around 130KB. When converted to an acceptable JPG quality however, the file size comes in at well under 50KB. Should I use JPGs in the application?
Thanks in advance,
It actually depends on the type of images.
The basic rule is to use JPEG for photos and PNG for everything else.
Why is it so?
JPEG compression is designed for photos - photos can handle lossy compression. On the other hand, PNG is compression designed for images which have similar pixels close to each other (straight lines, areas filled with one color, texts, etc.). If you try to use JPEG on an image which is not a photo, you'll be surprised - it won't look very good.
PNG is a standard - but for icons, backgrounds, patterns etc; not for photos.
Yes you can use jpg. You will not encounter any problem. It is a tradeoff between quality and size. Jpeg is usually smaller because it is compressed so as to reduce size. Png is lossless compressed.
I have made applications that use both png and jpeg and they both work like a charm.
EDIT: You can also check out this link PNG vs JPEG
PNG images are huge in size, use JPG as long as it's possible (when you don't need transparency)

web loadable 80x80 thumbnail images - best format choice if compression is done on the server

I've read many of the png vs. jpg threads here and elsewhere. I didn't find this aspect covered for small images that are downloaded from a server.
A short recap:
Xcode optimizes png images that are delivered with the app bundle in a way that they are optimized for the iOS hardware ("png magic")
png images support transparency (which I don't need)
png is the better choice from graphics, jpg for pictures (we have pictures)
I'm building an app that periodically downloads feeds that contain links to thumbnail images (size 80x80). These images are presented side by side the text content in a tableview. I can influence which format is used (jpg, png) on the server side.
If I use an uncompressed png format, it will have about 17k size for one image. This is quite large. And since this png doesn't use the "png magic" of Xcode, the iPhone still might need quite some cpu to get them into the table view compared to an "Xcode prepared" png.
The same image as a compressed jpg is only 3k which is great.
Question: are there lab comparisons that show the real world performance of these 2 formats?
Another one: has anyone used jpgs of a similar size (80x80, 3k) successfully in a table-view?
Many thanks in advance
What do you mean "lab comparisons"? PNG is going to do better with flat colors -- it uses variations on run-length and dictionary encoding as I understand. JPEG will be better with images containing subtle gradients, and loses data mostly in jumps in luminosity which are hard for the human eye to see. "Better" here refers only to file size. It sounds like you would want JPEGs here.

iPhone - vectorial format for iPhone/iPad

What is the best vectorial format I can use to create resolution independent vectorial artwork for iPhone and iPad? PDF?
I have to draw large images 1024x1300 images on a quartz context. Suppose I use PDF. What technique would save more memory and consume less CPU: have the PNG image loaded and draw it on the quartz context or have the PDF loaded on the quartz context?
thanks in advance.
The Opacity image editor allows you to draw vector graphics, and output Quartz2D code that you can then use to duplicate the image at any size on any iOS device:
http://likethought.com/opacity/
It would be blazing fast and use almost no memory (well, a large CALayer will consume memory)
As usual 'it depends'.
Using PNGs of that size will require 5MB of memory to keep them uncompressed in a buffer. This may be fine for your app.
Memory usage of a PDF document is very dependent on the complexity of that document. In my experience vector graphics and text are pretty efficient. Specially when rendered to a Layer.
I think you will simply have to put together a small proof-of-concept app and run it in Instruments to get some real numbers.