{"id":1508,"url":"https://github.com/yapstudios/YapImageManager","last_synced_at":"2025-08-02T04:31:25.197Z","repository":{"id":56930138,"uuid":"90908662","full_name":"yapstudios/YapImageManager","owner":"yapstudios","description":"A high-performance image library for downloading, caching, and processing images in Swift.","archived":false,"fork":false,"pushed_at":"2018-07-11T00:28:16.000Z","size":2135,"stargazers_count":72,"open_issues_count":2,"forks_count":14,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-22T12:34:25.243Z","etag":null,"topics":["image","ios","swift","yapdatabase"],"latest_commit_sha":null,"homepage":"https://yapstudios.com","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yapstudios.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-10T21:10:33.000Z","updated_at":"2024-05-13T07:55:24.000Z","dependencies_parsed_at":"2022-08-21T05:50:18.764Z","dependency_job_id":null,"html_url":"https://github.com/yapstudios/YapImageManager","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yapstudios%2FYapImageManager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yapstudios%2FYapImageManager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yapstudios%2FYapImageManager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yapstudios%2FYapImageManager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yapstudios","download_url":"https://codeload.github.com/yapstudios/YapImageManager/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228438934,"owners_count":17920017,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["image","ios","swift","yapdatabase"],"created_at":"2024-01-05T20:15:48.097Z","updated_at":"2024-12-06T08:31:06.461Z","avatar_url":"https://github.com/yapstudios.png","language":"Swift","funding_links":[],"categories":["Media","Swift"],"sub_categories":["Image","Other free courses"],"readme":"![YapImageManagerLogo](Docs/header.gif)\n[![Build Status](https://travis-ci.org/yapstudios/YapImageManager.svg?branch=master)](https://travis-ci.org/YapImageManager/YapImageManager)\n[![CocoaPods Compatible](https://img.shields.io/cocoapods/v/YapImageManager.svg)](https://img.shields.io/cocoapods/v/YapImageManager.svg)\n[![Platform](https://img.shields.io/cocoapods/p/YapImageManager.svg?style=flat)](http://cocoadocs.org/docsets/YapImageManager)\n[![Twitter](https://img.shields.io/badge/twitter-@yapstudios-blue.svg?style=flat)](http://twitter.com/yapstudios)\n\n## Features\n- [x] Asynchronous image downloader with priority queuing\n- [x] Advanced memory and database caching using [YapDatabase](https://github.com/yapstudios/YapDatabase) (SQLite)\n- [x] Guarantee of only one image download per request\n- [x] Cancellation of pending requests with ticket\n- [x] Background image decoding, resizing and filtering\n- [x] Custom image filters\n- [x] Image rendering of gradients and more using filters\n- [x] High performance scrolling\n- [x] Automatic pause and resume of download queue on reachability changes\n- [x] Written completely in Swift\n\n## Roadmap Features\n- [x] Ability to capture image height and width from the raw decoded image data stream, **before the image is downloaded** via a notification, for gif, png, and jpeg formats. This is extrememly useful for displaying full width images with the proper aspect ratio in a table view or collection view, by enabling you to calculate the cell height and update the layout almost immediately while the visible images are downloading.\n- [x] Ability to return an image with the first frame of a GIF before the entire GIF is downloaded.\n- [x] Ability to convert GIFs to MP4 files for better memory managment and scrolling performance\n\n\n## Requirements\n\n- iOS 10.0+ / tvOS 9.0+\n- Xcode 8.0+\n- Swift 3.0+\n\n## Installation\n\n### CocoaPods\n\nYapImageManager supports [CocoaPods](http://cocoapods.org) for easy installation. Below is a sample podfile.\n\n```\nsource 'https://github.com/CocoaPods/Specs.git'\nplatform :ios, '9.0'\nuse_frameworks!\n\ntarget '\u003cYour Target Name\u003e' do\n    pod 'YapImageManager', '~\u003e 1.0.2'\nend\n\n```\n\n## Usage\n\n### Requesting a full-sized image\nBelow is an example of how to request a full-sized, decoded image and set the image response on a `UIImageView`.\n\n```\n  YapImageManager.sharedInstance.asyncImage(forURLString: URLString) { [weak self] response in\n    if let image = response.image {\n      self?.imageView.image = image\n    }\n  }\n```\n\n### Requesting an image of a specific maximum size\nBelow is an example of how to fetch a decoded image of a specific size and set the image response on a `UIImageView`. Requesting an image size that matches the bounds of your `UIImageView` can increase scrolling performance but avoiding a resize on the GPU. Decoded and sized images are cached in memory, reducing CPU time.\n\n```\n  YapImageManager.sharedInstance.asyncImage(forURLString: URLString, size: self.bounds.size) { [weak self] response in\n    if let image = response.image {\n      self?.imageView.image = image\n    }\n  }\n```\n\n### Requesting an image with a ticket for cancellation\nRequesting an image with a ticket is important for use in a `UITableView` or `UICollectionView` with recycling cells. When a cell is recycled, cancelling the ticket ensures that a prior image request will not complete and update the image of a new cell with a different image request. It also will improve performance by cancelling any unneeded download requests for cells that are no longer visible during fast scrolling. Below is an example.\n\nAdd the `ticket` member variable to your class...\n\n```\nprivate var ticket: ImageRequestTicket?\n```\n\nRequest the image, saving the ticket...\n\n```\n  ticket = YapImageManager.sharedInstance.asyncImage(forURLString: URLString, size: self.bounds.size) { [weak self] response in\n    \n    if response.ticket == self?.ticket {\n      self?.ticket = nil\n      \n      if let image = response.image {\n        self?.imageView.image = image\n      }\n    }\n  }\n```\n\nIn `prepareForReuse`, cancel the ticket...\n\n```\n  override func prepareForReuse() {\n    super.prepareForReuse()\n    \n    if let ticket = self.ticket {\n      YapImageManager.sharedInstance.cancelImageRequest(forTicket: ticket)\n      self.ticket = nil\n    }\n  }\n```\n\nBelow is the example output.\n\n![Sized Images](Docs/exampleSized.png)\n\n### Requesting an image with filters\n\nTo render an image with one or more image filters, simply pass an array of `YapImageFilter` in the request. YapImageManager has the following built-in filters:\n\n- `YapAspectFillFilter` - draws the original image with content mode aspect fill\n- `YapGradientFilter` - draws a gradient from a specified `startColor` to `endColor`\n- `YapColorFilter` - draws a background color, or overlay color, depending on whether you include before or after `YapAspectFillFilter`\n- `YapOverlayImageFilter` - draws a custom `UIImage` specified by `overlayImage`\n\nYou can create your own custom filters by adopting the protocol `YapImageFilter`. \n\nBelow is an example of adding a gradient overlay to an image. When using filters, be sure at least one filter renders the original image, for example using `YapAspectFillFilter`.\n\n```\n  let filters: [YapImageFilter] = [YapAspectFillFilter(), YapGradientFilter(startColor: UIColor.black.withAlphaComponent(0.5), endColor: .clear)]\n  YapImageManager.sharedInstance.asyncImage(forURLString: URLString, size: self.bounds.size, filters: filters) { [weak self] response in\n    if let image = response.image {\n      self?.imageView.image = image\n    }\n  }\n```\n\nBelow is the example output.\n\n![Sized Images with Gradient](Docs/exampleSizedWithGradient.png)\n\n### To render a new image, for example a gradient\n\nTo render a new image using filters, use the `createImage` method passing in the desired size and an array of `YapImageFilter`. The following example generates a simple overlay gradient.\n\n```\n  let red = UIColor(red: 0.93, green:0.09, blue:0.31, alpha:1.0)\n  let gradient = YapGradientFilter(startColor: red, endColor: .clear)    \n  YapImageManager.sharedInstance.createImage(withSize: self.bounds.size, filters: [gradient]) { [weak self] image in\n    self?.imageView.image = image\n  }\n```\n\nBelow is the example output.\n\n![Gradient Images](Docs/exampleGradient.png)\n\n## Credits\n\nYapImageManager is owned and maintained by [Yap Studios](http://www.yapstudios.com).\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyapstudios%2FYapImageManager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyapstudios%2FYapImageManager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyapstudios%2FYapImageManager/lists"}