Downloading Images on iPhone - How does Facebook do it? - iphone

How does the Facebook app go about downloading/displaying the images in photo galleries? They appear to load in at varying times which would indicate some degree of threading? Surely the app doesn't spawn X amount of threads (where X is the number of pictures) as this would cause performance issues? Can anyone enlighten me as I would like to use something similar in my app (I will be regularly downloading a large amount of photos and displaying them in the app so downloading them one after another takes too long). Also, these photos change on a fairly regular basis so downloading once and cacheing isn't really an option.
Is there some kind of framework/solution around that might help me achieve something similar to Facebooks galleries?
Thanks,
Jack

The code the Facebook app uses to do this has been open-sourced as the three20 library. This functionality is provided in TTPhotoViewController.

Have a look at the LazyTableImages example from Apple. The images are downloaded asynchronously and have a reference back to where they are supposed to be displayed.

I would recommend you use this Library, ASIHTTPRequest, which is like an extended version of the NSURLRequest. I have been using it to download images for later display, asynchronously. It has a nice CACHE implementation which saves bandwidth and loading times on your app.

Related

Personalized Video / Facebook App - What is the best approach?

I want to build a facebook app featuring a personalized video which imports content assets from the user's facebook profile and their extended social graph and integrates these assets within the timeline. I am thinking of using Flash however a key stipulation is that the app works on mobile - and so I would need to use HTML5. My question is: Can I use Flash to build the application and then compile the app as HTML5 - or is there an alternative solution in the form of a HTML5 video toolkit with a programming layer that would allow me to build a web app / access the Facebook API?
I have done this a few times over the years and yes flash was the easiest however there are a few options which you have available to you that I know of which will be purely HTML5 based, personally I'd stay away from flash here as it will end up just getting int he way:
1- The cleanest method is to use a video compositing tool on the server side which can be programmed to accept variables. Personally I have only ever done this using ffmpeg however there a couple of alternatives which are out there.
The basic process would be to grab the media from FB then to composite them at certain point on top/below/around a base video which is sitting on the server using a shell script which you then pass the media assets to as variables. There are so many options as to how you might want this to be done, probably best id to have a look at some of these examples:
http://broadcasterproject.wordpress.com/2010/05/18/how-to-layerremix-videos-with-free-command-line-tools/
http://graphcomp.com/ffmpeg/
ffmpeg watermark without vhook?
note that last time I did this I used vhooks and custom filters, vhooks are now deprecated
This method will mean a reasonably heavy server load if your app is popular but it's probably the most robust across devices etc.
2- Use Popcorn.js, and let the processing be done on the client side. you could hard code it using css/js/html but popcorn is pretty stable although I havent seen how it runs on devices but in theory it should work (all standardized technologies). Basically the process would be to use javascript to fire the display of images overlayed on the video base file at preset cue points. Popcorn has all of the methods and means for you to do this already.
Hope this helps a bit. Good luck, sounds fun.
we realised some interactive video apps and one recent project was quite like your question describes.
We used adobe flash to track the motion - and published the project via create.js. You could have an image sequence from within create.js or put a video in a layer behind. This video would then control the player head time of the create.js motion tracked sequence via jquery.
worked fine - here a link to a testsetup with an image sequence.
Video Integration would be the next step.
http://www.jungeroemer.net/projekte/testpersvid/elftest01.html
(German text, sorry but it's nothing important to read there.
Just click the images and go for it)
you can download the sources from the link, if you need i can also upload the flash file to show you the motion tracking.

Is there an iphone photo thumbnail viewer and browser that is easy to use?

I'm adding a thumbnail photo gallery to my iPhone app which will include an iPhone Photo App-like photo browser plus a detail view for each photo. So far the only thing I've found that provides this is Three20 -- the thing is that Three20 is so huge and has a complex looking API which is not a standard Apple style interface as far as I can tell.
I've also seen this post Open source photo viewer for IPhone which mentions a couple of other photo browsers -- but these don't have thumbnail galleries built in.
My question is: does anybody know of a good combination photo-browser and thumbnail gallery library which is easy to use, not excessively large and easy to customize? Cacheing is also crucial.
I have found an answer to my own question called KTPhotoBrowser which fits the bill exactly -- just a thumbnail gallery and photo browser. Combined with SDWebImage which handles the image cacheing it appears to be a perfect simple solution that doesn't require 2 MB of code!
Update: quick to install, works with tab bar controller (example app provided!) and works like a charm. May not have all the features of Three20 but its a lot easier to use and has a much smaller footprint. TabBarController woes made the final decision, I spent several hours trying to get Three20 photo viewer to play nice with my tab controller app -- and failed! After only a half an hour of futzing I got KTPhotoBrowser working by using their tab sample app as a reference point.
I know Three20 looks huge, but it is the best from my point of view. I also had problems to start, but I was able to make it. I have sample code here on stackoverflow and on github. Check it out, you will see that is exactly what you need.

iPhone: Efficiently downloading images from a URL into iPhone App

In my iPhone app , I need to display the images from server.
I need to download it and save it from URLs.
There are roughly 20 images which I need to download.
What could be a way out where in performance doesnt decrease?
I have tried previously using NSData to convert the images into NSData and saving it to my app but it takes lots of time.
What could be a more easier and efficient way out?
I recommend using ASIHTTPRequest to download the images asynchronously, and display them when they're ready. By using the asynchronous interface of that class, your app can be responsive and continue to operate normally while, in the background, you wait for the data to be loaded.
ASIHTTPRequest is open source and free to use: http://allseeing-i.com/ASIHTTPRequest/
The code the Facebook app uses to download and display images has been open-sourced as part of the three20 library.
If you want to write your own networking code ASIHTTPRequest is a very useful library that includes features such as downloading directly to a file and queue management.

creating iphone app for existing site. need advice about the data I'm downloading

I'm building an iPhone app for existing site (a local news site)
Main page with articles headers, when click on them you move to the article page. Simple.
This is the first time I'm building such type of app.
I have 3 general questions, just to make sure :
For the iphone, Do we need to
re-create the website article's
pictures for the iphone ? or there
is some programming tool that on the
fly make the files looks better on
the iphone ? or maybe, there is some
technique that creates one artice
picture that looks right both for
the server and the iphone ?
Usually, Do you need to create
special data channels from the
iPhone webservice ? or programmers
just use the existing rss channels
of the webserver ?
If someone know nice artice about
this stuff, It will help a lot. just
see what other are doing.
thanks.
You can see the intent Media apps, these apps are working like what you want your app to.
1) You're better off creating mobile versions of the images. You can do image processing on the iPhone, but you'll have to have the original and that makes the whole thing pointless (ie. you have to download the whole thing.) Generate a mobile thumbnail when those are uploaded on the server.
2) RSS will do. There's a very good tutorial at cocoadevblog.com about approaching such a task (I guess this covers 75% of the work you have to do)
3) Check 2) ;-)
if your download image is bigger the the thumbnail you are trying to display,
then the problem is in your code that change the image size. check carefully what are you doing to the image after downloading it.
I would recommend to create square thumbnails of your pictures at the server level. This will allow you to easily position in the iPhone screen, plus you will not need to download the whole image from the server.
nnahum

Displaying Photos on iPhone

I'm working on an iPhone app and I need to be able to display images to users. I have already gotten the code that takes the photo and stores it into the filesystem working well. Now I just need to figure out how to display the image.
I've looked at the Three20 project I've read about on a few of the posts here, but it seems a bit cumbersome and like an extra dependency to import link and combine all of the Three20 library into my little app.
Are there any other ways or a more streamlined library that will let me display photos to my users?
Thanks!
B.
Throw a UIImageView on the screen? Or ask a more specific question if that is not what you want.