gifu alternatives and similar libraries
Based on the "Images" category.
Alternatively, view gifu alternatives based on common mentions on social networks and blogs.
-
SwiftGen-Assets
The Swift code generator for your assets, storyboards, Localizable.strings, … — Get rid of all String-based APIs! -
GPUImage 2
GPUImage 2 is a BSD-licensed Swift framework for GPU-accelerated video and image processing. -
SkyFloatingLabelTextField
A beautiful and flexible text field control implementation of "Float Label Pattern". Written in Swift. -
GPUImage 3
GPUImage 3 is a BSD-licensed Swift framework for GPU-accelerated video and image processing using Metal. -
Brightroom
DISCONTINUED. 📷 A composable image editor using Core Image and Metal. [Moved to: https://github.com/FluidGroup/Brightroom] -
CTPanoramaView
A library that displays spherical or cylindrical panoramas with touch or motion based controls. -
FMPhotoPicker
A modern, simple and zero-dependency photo picker with an elegant and customizable image editor -
AXPhotoViewer
An iOS/tvOS photo gallery viewer, useful for viewing a large (or small!) number of photos. -
PassportScanner
Scan the MRZ code of a passport and extract the firstname, lastname, passport number, nationality, date of birth, expiration date and personal numer. -
Harbeth
🎨 GPU accelerated image / video and camera filter library based on Metal. Support macOS & iOS. 图像、视频、相机滤镜框架 -
JLStickerTextView
add text(multiple line support) to imageView, edit, rotate or resize them as you want, then render the text on image -
XAnimatedImage
XAnimatedImage is a performant animated GIF engine for iOS written in Swift based on FLAnimatedImage -
UIImageView-BetterFace-Swift
DISCONTINUED. autoresize images and if any face discovered refine the position of the image. -
SwiftDraw
Swift library and command line tool to convert SVGs into SFSymbol, PNG, PDF and Swift source code. -
KFSwiftImageLoader
An extremely high-performance, lightweight, and energy-efficient pure Swift async web image loader with memory and disk caching for iOS and Watch. -
MCScratchImageView
A custom ImageView that is used to cover the surface of other view like a scratch card, user can swipe the mulch to see the view below. -
FacebookImagePicker
DISCONTINUED. FacebookImagePicker is Facebook album photo picker written in Swift. -
DTPhotoViewerController
A fully customizable photo viewer ViewController to display single photo or collection of photos, inspired by Facebook photo viewer.
CodeRabbit: AI Code Reviews for Developers
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of gifu or a related project?
Popular Comparisons
README
Gifu adds protocol-based, performance-aware animated GIF support to UIKit. (It's also a prefecture in Japan).
Install
Swift Package Manager
Add the following to your Package.swift
file:
let package = Package(
dependencies: [
.package(url: "https://github.com/kaishin/Gifu.git", from: "3.2.2")
],
)
Carthage
- Add the following to your Cartfile:
github "kaishin/Gifu"
- Then run
carthage update
- Follow the current instructions in Carthage's README for up to date installation instructions.
CocoaPods
- Add the following to your Podfile:
pod 'Gifu'
- You will also need to make sure you're opting into using frameworks:
use_frameworks!
- Then run
pod install
with CocoaPods 0.36 or newer.
How It Works
Gifu
does not require using the built-in GIFImageView
subclass. The Animator
class does the heavy-lifting, while the GIFAnimatable
protocol exposes the functionality to the view classes that conform to it, using protocol extensions.
The Animator
has a FrameStore
that only keeps a limited number of frames in-memory, effectively creating a buffer for the animation without consuming all the available memory. This approach makes loading large GIFs a lot more resource-friendly.
The figure below summarizes how this works in practice. Given an image containing 10 frames, Gifu will load the current frame (red), buffer the next two frames in this example (orange), and empty up all the other frames to free up memory (gray):
Usage
There are two options that should cover any situation:
- Use the built-in
GIFImageView
subclass if you don't need to combine GIF support with another image library. - If you need more flexibility and composability, make your class conform to
GIFAnimatable
. In practice, anyUIView
subclass would do, since you get most of the required properties for free. For best results, make yourUIImageView
subclass conform toGIFAnimatable
to get access to other features such as intrinsic content size.
GIFAnimatable
The bread and butter of Gifu. Through protocol extensions, GIFAnimatable
exposes all the APIs of the library, and with very little boilerplate, any class can conform to it.
class MyImageView: UIImageView, GIFAnimatable {
public lazy var animator: Animator? = {
return Animator(withDelegate: self)
}()
override public func display(_ layer: CALayer) {
updateImageIfNeeded()
}
}
That's it. Now MyImageView
has access to all these methods and properties:
prepareForAnimation(withGIFNamed:)
andprepareForAnimation(withGIFData:)
to prepare the animator property for animation.startAnimatingGIF()
andstopAnimatingGIF()
to control the animation.animate(withGIFNamed:)
andanimate(withGIFData:)
to prepare for animation and start animating immediately.frameCount
,isAnimatingGIF
, andactiveFrame
to inspect the GIF view.prepareForReuse()
to free up resources.updateImageIfNeeded()
to update the image property if necessary.
Furthermore, you can make any class GIF-animatable, starting with UIView
subclasses:
class CustomAnimatedView: UIView, GIFAnimatable {
public lazy var animator: Animator? = {
return Animator(withDelegate: self)
}()
override public func display(_ layer: CALayer) {
updateImageIfNeeded()
}
}
You can also make UIKit
classes conform using associated objects may you wish:
import UIKit
import Gifu
extension UIImageView: GIFAnimatable {
private struct AssociatedKeys {
static var AnimatorKey = "gifu.animator.key"
}
override open func display(_ layer: CALayer) {
updateImageIfNeeded()
}
public var animator: Animator? {
get {
guard let animator = objc_getAssociatedObject(self, &AssociatedKeys.AnimatorKey) as? Animator else {
let animator = Animator(withDelegate: self)
self.animator = animator
return animator
}
return animator
}
set {
objc_setAssociatedObject(self, &AssociatedKeys.AnimatorKey, newValue as Animator?, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
}
Examples
The simplest way to get started is initializing a GIFAnimatable
class in code or in a storyboard, then calling animate(:)
on it.
let imageView = GIFImageView(frame: CGRect(x: 0, y: 0, width: 200, height: 100))
imageView.animate(withGIFNamed: "mugen") {
print("It's animating!")
}
You can also prepare for the animation when the view loads and only start animating after a user interaction.
// In your view controller..
override func viewDidLoad() {
super.viewDidLoad()
imageView.prepareForAnimation(withGIFNamed: "mugen") {
print("Ready to animate!")
}
}
@IBAction func toggleAnimation(_ sender: AnyObject) {
if imageView.isAnimatingGIF {
imageView.stopAnimatingGIF()
} else {
imageView.startAnimatingGIF()
}
}
If you are using a GIFAnimatable
class in a table or collection view, you can call the prepareForReuse()
method in your cell subclass:
override func prepareForReuse() {
super.prepareForReuse()
imageView.prepareForReuse()
}
Demo App
Clone or download the repository and open Gifu.xcworkspace
to check out the demo app.
Documentation
See the full API documentation.
Compatibility
- iOS 9.0+
- Swift 4.0
- Xcode 9.0
License
See LICENSE.
*Note that all licence references and agreements mentioned in the gifu README section above
are relevant to that project's source code only.