Exporting PNG-Sequences for iOS right! - ios

I made an animation for an iOS-loading-screen. The devs tell me now, that the files are way to big (100 frames/pngs with 22.5mb for the whole bunch) and I tried to reduce it by rastering the PNGs by export (helped a bit) and then I shortened the video by 50frames and I'm on 10mb now. This is still huge. I made the animation in Flash. Is this the problem? Each PNG is 235kb of size. I need your help :-)

first try to reduce the size of your png using pngcrush or Photohop export for web. The other idea is to use an mpeg video, create a png with just the first frame, open the video when the application run and you should be able to switch from the static png to the first frame of the video without glitches. In this way the user don't understand that you switched from image to video and see the video playing.
Hope this helps

Related

Reducing iOS App file size

I have made a very simple iPhone app with Xcode 6.1 and swift. I am really new to ios developing and ran into an app which in the end is 134 mb! of course this is not acceptable.
I have background images for all screen sizes which add up to 20 mb. and thats it! I am storing those images in xcassets, as thats the preferred way I guess.
the app shouldnt have more than 25 mbs, I think.
I figured out that I had some references doubled in my project. I removed these and still my .app file is 89 mbs!
What am I doing wrong? I read several threads on this, but nothing really helped!
What I did until now:
- reduce the size of all pngs
- disable the compress PNG option, as it seems to make the PNGs bigger (lol)
- configured the build settings to run the fastest and smallest build
- Strip Debug Symbols During Copy build setting to Yes (COPY_PHASE_STRIP = YES)
edit1: Apparenty Xcode does something weird with my pngs. Some of those pictures, that are 2 mb originally, are more than 10mb in the .app-file. What does xcode do there ?
It is actually not surprising that the Apple recompressed files are bigger. They are optimized for fast load not small size. If you do not care about size over speed, defiantly do turn off the compression. Even if you do care about speed you can do better than Apple.
https://imageoptim.com/xcode.html
So yes, turn off the PNG compression. The first thing I would do is build the ipa. An ipa is actually a zip file so build the ipa, copy it to a folder on your mac, rename the file with a .zip extension and double click on it. This will expanded it. Find the app in the Payload folder and right mouse click on it and choose show package contents. You will see all the assets. Sort by size. I am guessing you have overly large images. At that size my guess is that the extra size is likely to be caused almost entirely by the PNG files.
Consider using non retina images for some. Honestly most people wont notice. iOS will gracefully use the non retina on retina. This can save a ton of space,
Also consider using jpeg files instead of PNG for some of the files if you do not need transparency. Jpeg files are less efficient but can be much smaller. Compare both. Depends on the extent to which the images are continuous tone.
By default PNG file are 32 bit. 24 bit color and 8 buit alpha/transparency. You can save a bit of size by going to 24 bit. You can also save a lot of size going to 16 bit color or below. At 8 bit PNG files use a color lookup table. Play with Photoshop and the save for we options at PNG with bit depth 8 and below.
I have all sorts of expensive compressing software but often use the $8
https://itunes.apple.com/us/app/lossless-photo-squeezer/id704083918?mt=12
Try the 8 bit PNG option and the JPEG options.
EDIT
I did some research. I had always know Fireworks did better PNG compression. I did not realize that there was an 8bit PNG with an 8 Bit alpha channel. Photoshop supports 8 bit with a 1 bit Alpha Channel. I have always told people to use 32 bit PNG if their transparency needed more than 1 bit. In the future I will let them know the 8 bit with 8 bit alpha may be the better route, They just can use Photoshop for the final save of the file. They just need to save a 32 bit and compress elsewhere.
http://calendar.perfplanet.com/2010/png-that-works/
David

How to get frame by frame images from movie file in iPhone

In iOS, I would like to get frame-by-frame images from a movie file,
I tried it by using AVAssetImageGenerator. But it gets one image per second for a 30fps movie. It should be 30images!
I heard that there is a way to use FFmpeg.
But in newer OSs like iOS7, is there a new API to do this without using external libraries like FFmpeg?
You can also try OpenCV to capture the frames. But the speed will be dependent on the device and processor. Hope for iPhone5 the speed is perfect to capture all the frames. You can have a look at this link if it helps.

iOS faster way to update UIView with series of JPEGs ie MJPEG. (Instruments shows 50% CPU)

I'm receiving a series of JPEGs over the network from a camera (MJPEG). I display the images as I receive them in a UIView. What I'm seeing is that my App is spending 50% of CPU (device and simulator tested) in what appears to me to be the UIView update.
Is there is a less CPU intensive way to do this screen update? Should I process the JPEG in some way before handing it over to UIView?
Receive method:
UIImage *image = [UIImage imageWithData:data];
dispatch_async(dispatch_get_main_queue(),^{
[cameraView updateVideoImage:image];
});
Update method:
- (void) updateVideoImage:(UIImage*)image {
myUIView.image = image;
...
update: added better screen capture
update2: Is OpenGL going to provide a quicker surface to render to for JPEG? It's not clear to me from Instruments where the time is being spent, render or decode. I'm going to put together a test case as suggested and work from there.
iOS is optimized for PNG images. While JPEG greatly reduces the size of images for transmission, it is a much more complex format, so it does not surprise me that this rendering is taking a lot of time. People have said there is jpeg hardware assist on the device, but I do not know for sure and even if its there it maybe tuned for certain image types.
So - some suggestions. Devise a test where you take one jpeg you have now, and render it to a context, and baseline this time. Take the same image and open it in Preview, then save it with a slightly different quality value to another file, and try that (Preview will strip out unnecessary "junk" from the image, or even convert it first to a png then back to a jpeg. The idea here is to use an image output from Preview, which is going to be as clean an image as you are going to get. Is the image any better?
You can also try using libjpegturbo, and see if it can render your images faster. You can see that library in action in a github project, PhotoScrollerNetwork. You may find that project of use as it decodes the jpegs (using that library) in real time as they are received, and then supports zoomable viewing using CATiledLayers.

can I use jpg instead of png for a iOS web app startup image?

I'm fiddling with the iOS startup image.
Both tutorials I found
http://mathiasbynens.be/notes/touch-icons
https://gist.github.com/472519
are using .png images for the splash screen. I have tried to reduce my png files size, but for the large splashscreens, I'm well over 500k, which is too much for me. So I tried using jpg, which also seems to work, but I'm not sure I'm doing the right thing when switching from PNG to JPG.
Here is my code for inserting the splash screen (lost the link to the original author... :-(
It's inserted as script, because iOS is said to load every specified image although only one image is needed. The script ensures only a single splash screen is inserted into the DOM and thus avoids unnecessary http requests.
<script>
(function(){var a;if(navigator.platform==="iPad") {
a=window.orientation===90||window.orientation===-90 ?
"landscape.jpg" : "portrait.jpg"
} else {
a=window.devicePixelRatio === 2 ? "retina.jpg" : "startup.jpg"
}
document.write('<link rel="apple-touch-startup-image" href="'+a+'"/>')})()
</script>
My questions:
1. Should I use JPG over PNG to cut down on file size?
2. How can I reduce my PNG file size? (I used optipng, but 20% of 800k is still 640k)
Thanks for hints!
I use JPG files on my site and they work just fine. Just make sure you optimize for web when you save, and make sure the image dimensions are exactly correct. See here (the page mainly talks about splash images for an actual native app, but the information also applies to web apps): http://developer.apple.com/library/ios/#documentation/userexperience/conceptual/mobilehig/IconsImages/IconsImages.html

How to merge a jpg with a gif without lossing the animation of gif file?

I am trying to merge a splash screen image which is in jpg format with an ajaxloader which is in gif format.
I tried the following command using ImageMagik:
convert -delay 50 splashimage.jpg ajaxloader.gif final.gif
This command does merge the gif file with the jpg image but the loader appear at the top-left corner.
I was wondering if there is an option available to place it at a specfic (x,y) point on the jpg image?
If anybody has had done a similar thing or has an idea as to how a similar thing can be achieved, please guide me through.
Thanks.
Why would you want to do this? You'd be turning a nice 24bit JPG into a crappy quality single frame on an 8bit gif. You could just use some CSS tricks to overlay the loader .gif on top of the .jpg on a webpage, which would not sacrifice any image quality to achieve the same effect.
I solved the problem by designing individual frames of images with the desired location of my text and merged them using Imagemagik.

Resources