Giter Site home page Giter Site logo

uiimage-from-animated-gif's Introduction

Summary

This project defines a category animatedGIF on UIImage. The category defines two methods. This method creates an animated UIImage using the frames of the GIF in data:

+[UIImage animatedImageWithAnimatedGIFData:(NSData *)data]

This method creates an animated UIImage using the frames of the GIF loaded from url:

+[UIImage animatedImageWithAnimatedGIFURL:(NSURL *)url]

Look at the comments in UIImage+animatedGIF.h for details.

You can build and run the project to see a trivial demo app.

To use this category in your own project

  1. Copy UIImage+animatedGIF.h and UIImage+animatedGIF.m to your project.
  2. Add UIImage+animatedGIF.m to your target's “Compile Sources” build phase, if you didn't tell Xcode to do that when you performed step 1.
  3. Add ImageIO.framework to your target's "Link Binary With Libraries" build phase.

Implementation notes

The implementation of this category uses the Image I/O Framework to extract the images and durations from the GIF data.

Diego Peinador provided the inspiration for handling variable-frame-rate animations, although I didn't end up using his code.

Copyright or lack thereof

The contents of this repository are dedicated to the public domain, in accordance with the CC0 1.0 Universal Public Domain Dedication, which is reproduced in the file COPYRIGHT.

Author: Rob Mayoff 2012-01-27

uiimage-from-animated-gif's People

Contributors

aroben avatar mayoff avatar vivid-cieslak avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uiimage-from-animated-gif's Issues

Gif data not being released

I can't figure out if I am doing something wrong but the memory use of my app does not go down after I nil a gif image. Any thoughts?

Slow gif

Please help. Some gifs are playing really slow. I'm getting the duration of the gif, and most gifs have 1s, and a few have 9s10s.
But if I check the duration of the gif manually, with an .exe i have in my Windows computer, it says the gifs have around 1s
2s.
Does anyone knows what is causing this?
Btw, i'm using the latest swift version.

This isnt asynchronous :(

I am trying to use this in a uitableview and parsing the links from the web. but the problem is that this library is not Asynchronous. Any future plans to support that?

image disappearing in UITableViewCell

I'm using an animated image inside a UITableViewCell and when I scroll the image off screen, all the images disappear and I only see the background of the UIImageView.

Anyway to stop animation? Pause or otherwise?

Maybe this is outside the scope of the library, which is amazing by the way, but it would be really cool to be able to stop the animation?

There is a simple solution/hack of having a reference frame uiimage as well as the animated one, but if there were a way to pause the gif that would be awesome.

What license is this under?

Hey there,

What license is this released under? It would be really awesome if it was under the MIT license.

Thanks!

Methods to find length of .gif and if it is animating

The regular [UIImage isAnimating] method is not working and it would be great if I could get the total length of an animated gif. -1 if it is an infinite animation. Finally, the ability to stop/start an animation at a given frame would be great.

Any way to load faster?

I put it into a background thread, still not fast enough. Any suggestions?

int i = 0; for (UIImageView *imageView in self.featuredPhotoImageViewCollection) { dispatch_async(dispatch_queue_create("imageQueue", NULL), ^{ NSURL *url = [NSURL URLWithString:[featuredPhotos[i] valueForKey:@"url"]]; UIImage *image = [UIImage animatedImageWithAnimatedGIFURL:url]; dispatch_async(dispatch_get_main_queue(), ^{ imageView.image = image; }); }); i++; }

Converting back to data?

Finally got the gif off the pastboard and onto the screen. Problem is I can't get it off the textView and back into NSData. Using UIImagePNGRep... doesn't work. How can I convert the image back to data without saving it in a property?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.