PDF vector graphic smaller than the png at same size - ios

I converted some SVG images into PDF and png files for my iOS app. When adding them to the UIImageView, the pdf images look smaller than the png equivalent. The scale type was set to center, so no scaling happens at runtime.
btw, the pdf and png look the same when I open them in preview and adobe reader
Anyone had same issue and got a solution for that?

When converting an SVG to PDF, make sure the DPI is set to 72. That way, the size will match with the PNG resource that you have. Xcode actually expects vector-based resources to be 1x in size.

Related

How to export all layers in PSD file to PDF vector to use asset catalog in Xcode 6

As far as I know, Apple has new approach to create images for 3x called PDF vector image.I have a PSD file (with multiple layers for many icons) and now I want to export all layers to pdf vector image to use asset catalog.
I also refer this tutorial but i don't understand how to do for step 1.
http://martiancraft.com/blog/2014/09/vector-images-xcode6/
How can i do that? Please give some solution to do that. Thanks in advance.
You can use vectorized PDF files in Xcode in the 1x slot.
When you compile your project, Xcode automatically will generate the PNG files for each required resolution (1x, 2x and 3x). (You final project won't have the PDF file)
To use that feature you need to have a vectorized image (SVG, EPS or AI) and print them to vectorized PDF. (PSD is not a vectorized format)
I usually use SVG files and I print to Vectorized PDF with this page http://www.fileformat.info/convert/image/svg2pdf.htm
If you have a PSD file, you can save your layers to PNG in the 3x resolution and put each PNG in the 3x slot. When you do that, XCode automatically will generate the 1x and 2x images resizing the 3x image.
Hope this helps

Xcode generates png form pdf with different colors

We are following article to use pdf vector resources in iOS project: http://martiancraft.com/blog/2014/09/vector-images-xcode6/
However we faced problems. If we set color in Photoshop/Illustrator to #039AF0 then exported pdf will generate png with #1185ec color.
If we use old png way then colors are fine (please ignore pixelized image, the most important is color):
What can be the cause?
When a new artboard is created in Illustrator it defaults to using Adobe RGB for the color space which doesn't work well with iOS. To make sure the colors remain as close to the original as possible, set the color space to sRGB by selecting "Web" for Profile and RGB for Color Mode under Advanced.
This works well for new artboards. I have an Illustrator file as a deliverable that was created in Adobe RGB. For such cases, I've resorted to copy pasting vector paths on a new artboard that's set to sRGB before saving as PDF for use in Xcode 6.
I got the same problem, and finally I found that set the deployment Target to 7.0 or above solves the problem.
It is possible that Photoshop/Illustrator generates CMYK or other special colors in the PDF file and Xcode uses the PDF rendering engine that is implemented in iOS to convert the PDF files to PNG.
Because the iOS has problems with displaying CMYK colors, your PNG image has distorted colors.
The above is only an assumption because I have not seen a sample PDF file and the process used by Xcode to convert the PDF to PNG is not documented.

Are there known issues with PNG and JPEG images generated on iOS?

I got the brilliant idea to generate the app store screen shots for my app from... and app! This works great, except for the fact that some of the PNG or JPEG images are not recognized as valid screen shots when I try to upload them. I checked with image viewer, and they have the required size, colorspace and pixel density.
Is there perhaps some strange issues with PNG and/or JPEG images generated on iOS?

Availability of background transparency for jpeg images

I need to edit a png image,by giving it border and drop shadow effect. But the final size of the edited image is too high to use for a mobile app .I know that size of jpeg is less compared to that of png.So i convert that image to jpeg and tried to give drop shadow and border effect.But that image is not having transparent background..Is their any other methods to accomplish this using jpeg?
Another option is to try either ImageOptim for losseless compression, or its lossy cousin, ImageAlpha.
ImageOptim tries a series of lossless algorithms to shrink a PNG and selects the smallest result of the bunch. It has taken 25% to 50%+ of quite a few of our images.
ImageAlpha, on the other hand, is lossy and can further crunch the image, with results more like JPEG but without losing Alpha.
You would also do well to disable PNG compression in Xcode as shown here, with additional details here.
What #minitech wanted to say is not about scaling, it's about file compression. jpg and png files usually have some data that could be removed from the file. There are some compression methods to reduce file size (note that is size in kbs, not in scale measurement). Jpg images can reduce file size by reducing image quality, too.
If you want another file type that accepts transparency, there are the gif format, which gives you a smaller file, but have some drawbacks, like a lack of alpha channel (variable transparency). Check this link for more details: http://www.w3.org/QA/Tips/png-gif
There are a couple of online file compressors. If you want to compress png files, you could try using http://tinypng.org/
No, jpeg image wont support transparency.But you can change the white background coming along with jpeg image

Batch processing SVG to PNG with borders

I have an SVG file and I need to export it to PNG in almost 1,000,000 different sizes (height 32-1000px and width 32-1000px).
But there is a catch, the SVG image itself has a width to height ratio of 2:1. So, when the PNG is 400x200 its an easy convert, but when the PNG is 600x200, then there needs to be a whitespace fill on the sides so that the image doesn't get distorted.
Any tools that can do this?
I have made svgexport for that but currently it centers and crops the output instead of padding (now it supports both cropping and padding).
Try inkscape editor. This editor is reference standard for SVG format. Inkscape has rich commandline support for exporting. More info: INKSCAPE manual for command line export

Resources