Is there a way to not add 1x images to an iPhone/iPad app?
I'm developing an iPhone app and also testing on my iPad.
When I just use #2x images, the iPad successfully resizes down to the 1x size.
Is there any downside to not to add 1x images? Or are they still important?
By forcing the device to downsample, you're sacrificing performance and memory for a negligible amount of disk space. It's a really bad trade-off. Plus, downsampling a larger image on the fly on the device is likely to use a lower-quality downsampling algorithm than what's available in, say, Photoshop (for performance reasons).
I had an app with 100+ near-fullscreen photos, and dropping the #1x versions made possible to keep the app below the 50 MB limit for downloading over a cellular connection.
In my case, I had no choice, but as #Kevin Ballard mentions, perhaps the trade-off is not worth it. Remember that non-retina images are 25% the size of the retina ones, so in terms of pixels you are only going from 1.25 to 1.00.
Granted, with compressed images the relation might not be linear (i.e., #1x PNG/JPEG may weight more than 1/4 of the equivalent #2x image on disk).
Related
I have 2 iOS apps that have been in the market, 3 years on iPhone, 2 years on iPad HD version. The apps are a popular reference tool in the medical field. They are both comprised of 1100+ images. The current app size is roughly 52mb.
Approximately 400 images will be redone. They are currently jpg and low resolution. The replacements will be png, with higher resolution.
I'm uncertain on pixel size for these images. If they are in the 280x280 range, each file is about 100k, if in the 560x560 range, each file is almost 400k.
So I'd be looking at additional 40mb for the smaller images and 160mb for the larger.
There are plans for another 400+ images in the near future. So, I'm somewhat concerned with final app size.
If I went with the larger size for Retina devices, can I downsize for non-Retina devices?
If I supplied both sizes, image.png and image#2x.png, that would be 200mb just for these images.
I'm a little uncertain on how to manage these with regards to their individual size and, more importantly, their total size.
Any comments or suggestions are welcomed and would be helpful.
TIA,
jb
Here are a few options you have:
1. Downsizing Retina Images
I would not recommended downsizing retina images for the non-retina devices. This produces non-optimal performance and makes the images look bad. Your still loading in all the pixels of a retina image, but only displaying 1/4 of them.
2. Bundling All of the Images
Honestly for a medical reference app, I think it would be understandable if your app size would be quite large. I wouldn't imagine people would need to download this app over 3G or LTE. Your users understand this is a large database app which provides high resolution images, thus they should be okay with the large app size via this method.
3. Hosting the Images on a Web Service
Another alternative would be to host the images on a server, allowing them to be downloaded individually as needed, or in bundles. I think your users would prefer being able to fully use the app without internet connection rather than having a smaller app size.
4. Alternative Image Loading
This approach takes a bit of work and could be a little risky. You could bundle only 2x versions of your images into the app. Then on App launch you could force the user to wait until you resize all the images to their 1x counterparts and save them off to the disk. Then you could create an image loading convenience method which loads a UIImage from either disk or the app bundle based on whether or not it needs a retina image.
I definitely recommend option 2 for your purposes. I only mentioned the others to be thorough.
I've made an "magic" app with a lot of coins/playing-cards.
Therefore I have a lot of images of coins, dollar bills, playing cards etc. (regular + retina resolution)
This results in a relative big file size of the final app, which I would like to avoid; since it can't be downloaded without a wifi-connection.
Currently it's 48.6 mb when downloading it from the App Store.
The images (100+) is all .png's saved in two versions, for the regular and retina displays.
Is there anyway to optimize this and reducing the final file size of my app?
I've considdered only storing the big (#2x) .png's and the scaling them accordingly.
I have had a lot of success using ImageOptim to compress the size of images in my application.
Also, if your images are png-24, you can reduce them png-8 and save a lot of space as well. png-8 doesn't support transparency though.
Why save 2 sizes? Do you have to display so many at a time that loading the retina version takes up too much memory on a 3G? Personally I don't think you should still think of supporting such an old device. Apple also dropped support for it a while ago and it really is lacking the memory for some decent applications.
Also, have you tried using some tools to compress your images without the users noticing it? like photoshop "save for web & devices", or yahoo's services etc.
why do you need to store TWO versions of images? Just use hires imges in regular displays. Or, if you whant so, you can distribute 2 apps...
Are you shure, that your images has necessary sizes? i mean retina display has 680x920 pixels. if you are don't zooming images, you don'n need to make them bigger. And in this case, mb *.app file, in archive... there must be 1000 images...
I have an app which display images in full Screen. Some of the images are 1952x3680 pixels and these images are raising memory warning level=1 and level=2.
How should i handle these image?
Scale your images down considerably. There is absolutely no reason you need images at that resolution in an iPhone app.
Don't use them. Either get your server to deliver a thumbnail version of the image (maybe using a thumb.php/jsp/asp/... file with GET params x=<width>&y=<height>), or scale the image down on the iPhone and discard the original data. The former method is vastly preferred as it saves on both bandwidth and large memory allocations client-side.
The largest images you should be working with are 480x320 (iPhone 3GS and earlier) and 960x640 (iPhone 4).
EDIT: The other situation I didn't think of is if you're bundling these images with the app. Please, please don't do that. If you have images that big, scale them down in Apple's Preview or any image editor to the sizes noted, and ideally have two copies, image.png and image#2x.png which are shown depending on the scale of the device's screen.
The screen itself is only 320x460 (not considering the clock bar on top), and 640x960 for retina display. There is no reason to have images this large to begin with. Scale them down. It'll both prevent the memory warnings and stymie unnecessary image size.
As said before, scale it down if you only want to show the image without zooming in fullscreen.
If you need to zoom and show it detailed, google for CATiledLayer. There are good examples around.
I have a question RE Retina display graphics (and potentially iPad 2 graphics if the rumours of double resolution displays are to be believed).
Is there any advantage to having two graphics:
Graphic.png 480x320
and
Graphic#2.png 960x640
and letting the iPhone use the #2 version for retina displays rather than just having Graphic.png at the higher res and letting iPhones with normal displays squash it?
Yes. If you didn't use two separate graphics (normal and "#2x"), any device without the retina display would have to store its graphics using four times as much memory. It's a simple matter of storing an insignificant amount of compressed images (PNGs) so you don't have to kill legacy devices' memory.
Not only that, but performance will drop from having to handle such large images on devices that are generally slower.
Finally, the result of scaling huge images is usually really ugly, because UIKit uses the nearest-neighbor algorithm when scaling.
Our graphics guy just gave me the sliced images for an Application we're building, but he only gave me the resolution for the 960x640 iPhone 4 res.
And advised that I can just scale the images down for 3g at runtime, so the resolution/image size remains the same but it's just displayed at half size.
The question: Is this allowed when submitting to the app store, or is it a requirement to have for example:
IMAGE1#2x.PNG (460x640) - iPhone 4
IMAGE1.PNG (230x320) - iPhone 3g
For all images.
I might just do the batch conversion and have two resolutions for all images, to save maximum space.
That's allowed, but obviously the images will occupy four times as much RAM on the older devices than they otherwise would, having four times the pixels. While the iPhone 4 has 512mb of RAM, the 3G and the original have just 128mb. Though assuming you are dealing with memory warnings correctly and everything will still fit, the main side effect will be performance issues whenever things are purged and later reloaded from disk (which, as I'm sure you're aware, is handled automatically for view controllers in NIBs). Based on empirical observations, the flash memory on pre-3GS devices is a lot slower than the later stuff so even if you're sticking with the large images it would make sense to attempt to minimise on-disk size.
Best practice that has worked for me is to make my retina image, then scale it down by 50%.
In order for the retina display to use the larger image, the #2x MUST be apart of the larger image. Your example is the way it should be used.
I would do the batch scaling ahead of time for sure. If for no other reason than the iPhone chooses whether or not to display the IMAGE1.PNG or the IMAGE1#2X.PNG depending on the resolution of the screen. In your code you always just reference IMAGE1.PNG. You don't have to make any coding changes. If you scale them at runtime you will have to override all of your calls to any UIImage type of thing.
IMHO, You are likely to miss one or else Apple is likely to release a different configuration of phone that will cause you to have to rework all of your code that is checking for screen resolution.