[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6915":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":23,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":16,"starSnapshotCount":16,"syncStatus":28,"lastSyncTime":29,"discoverSource":30},6915,"AlamofireImage","Alamofire\u002FAlamofireImage","Alamofire","AlamofireImage is an image component library for Alamofire","",null,"Swift",4028,520,69,11,0,1,3,30.15,"MIT License",false,"master",true,[],"2026-06-12 02:01:31","# AlamofireImage\n\n[![Swift](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSwift-6.0_6.1_6.2_6.3-orange?style=flat-square)](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSwift-6.0_6.1_6.2_6.3-orange?style=flat-square)\n[![Platforms](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPlatforms-macOS_iOS_tvOS_watchOS_visionOS-yellowgreen?style=flat-square)](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FPlatforms-macOS_iOS_tvOS_watchOS_visionOS-Green?style=flat-square)\n[![CocoaPods Compatible](https:\u002F\u002Fimg.shields.io\u002Fcocoapods\u002Fv\u002FAlamofireImage.svg?style=flat-square)](https:\u002F\u002Fimg.shields.io\u002Fcocoapods\u002Fv\u002FAlamofireImage.svg)\n[![Carthage Compatible](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FCarthage-compatible-4BC51D.svg?style=flat-square)](https:\u002F\u002Fgithub.com\u002FCarthage\u002FCarthage)\n[![Swift Package Manager](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSwift_Package_Manager-compatible-orange?style=flat-square)](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSwift_Package_Manager-compatible-orange?style=flat-square)\n[![Swift Forums](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FSwift_Forums-Alamofire-orange?style=flat-square)](https:\u002F\u002Fforums.swift.org\u002Fc\u002Frelated-projects\u002Falamofire\u002F37)\n\nAlamofireImage is an image component library for Alamofire.\n\n## Features\n\n- [x] Image Response Serializers\n- [x] UIImage Extensions for Inflation \u002F Scaling \u002F Rounding \u002F CoreImage\n- [x] Single and Multi-Pass Image Filters\n- [x] Auto-Purging In-Memory Image Cache\n- [x] Prioritized Queue Order Image Downloading\n- [x] Authentication with URLCredential\n- [x] UIImageView Async Remote Downloads with Placeholders\n- [x] UIImageView Filters and Transitions\n- [x] Comprehensive Test Coverage\n- [x] [Complete Documentation](https:\u002F\u002Falamofire.github.io\u002FAlamofireImage\u002F)\n\n## Requirements\n\n- iOS 10.0+ \u002F macOS 10.12+ \u002F tvOS 10.0+ \u002F watchOS 3.0+ \u002F visionOS 1.0+\n- Xcode 16+\n- Swift 6.0+\n\n## Migration Guides\n\n- [AlamofireImage 2.0 Migration Guide](https:\u002F\u002Fgithub.com\u002FAlamofire\u002FAlamofireImage\u002Fblob\u002Fmaster\u002FDocumentation\u002FAlamofireImage%202.0%20Migration%20Guide.md)\n- [AlamofireImage 3.0 Migration Guide](https:\u002F\u002Fgithub.com\u002FAlamofire\u002FAlamofireImage\u002Fblob\u002Fmaster\u002FDocumentation\u002FAlamofireImage%203.0%20Migration%20Guide.md)\n- [AlamofireImage 4.0 Migration Guide](https:\u002F\u002Fgithub.com\u002FAlamofire\u002FAlamofireImage\u002Fblob\u002Fmaster\u002FDocumentation\u002FAlamofireImage%204.0%20Migration%20Guide.md)\n\n## Dependencies\n\n- [Alamofire 5.11+](https:\u002F\u002Fgithub.com\u002FAlamofire\u002FAlamofire)\n\n## Communication\n\n- If you need to **find or understand an API**, check [our documentation](https:\u002F\u002Falamofire.github.io\u002FAlamofireImage\u002F).\n- If you need **help with an AlamofireImage feature**, use [our forum on swift.org](https:\u002F\u002Fforums.swift.org\u002Fc\u002Frelated-projects\u002Falamofire).\n- If you'd like to **discuss AlamofireImage best practices**, use [our forum on swift.org](https:\u002F\u002Fforums.swift.org\u002Fc\u002Frelated-projects\u002Falamofire).\n- If you'd like to **discuss a feature request**, use [our forum on swift.org](https:\u002F\u002Fforums.swift.org\u002Fc\u002Frelated-projects\u002Falamofire).\n- If you **found a bug**, open an issue and follow the guide. The more detail the better!\n- If you **want to contribute**, submit a pull request.\n\n## Installation\n\n### CocoaPods\n\n[CocoaPods](https:\u002F\u002Fcocoapods.org) is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate AlamofireImage into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\npod 'AlamofireImage', '~> 4.4'\n```\n\n### Carthage\n\n[Carthage](https:\u002F\u002Fgithub.com\u002FCarthage\u002FCarthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate AlamofireImage into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"Alamofire\u002FAlamofireImage\" ~> 4.4\n```\n\n### Swift Package Manager\n\nThe [Swift Package Manager](https:\u002F\u002Fswift.org\u002Fpackage-manager\u002F) is a tool for automating the distribution of Swift code and is integrated into the `swift` compiler. AlamofireImage supports its use on all supported platforms.\n\nOnce you have your Swift package set up, adding AlamofireImage as a dependency is as easy as adding it to the `dependencies` value of your `Package.swift`.\n\n```swift\ndependencies: [\n    .package(url: \"https:\u002F\u002Fgithub.com\u002FAlamofire\u002FAlamofireImage.git\", .upToNextMajor(from: \"4.4.0\"))\n]\n```\n\n### Manually\n\nIf you prefer not to use either of the aforementioned dependency managers, you can integrate AlamofireImage into your project manually.\n\n#### Embedded Framework\n\n- Open up Terminal, `cd` into your top-level project directory, and run the following command \"if\" your project is not initialized as a git repository:\n\n```bash\n$ git init\n```\n\n- Add AlamofireImage as a git [submodule](http:\u002F\u002Fgit-scm.com\u002Fdocs\u002Fgit-submodule) by running the following command:\n\n```bash\n$ git submodule add https:\u002F\u002Fgithub.com\u002FAlamofire\u002FAlamofireImage.git\n```\n\n- Open the new `AlamofireImage` folder, and drag the `AlamofireImage.xcodeproj` into the Project Navigator of your application's Xcode project.\n\n  > It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.\n\n- Select the `AlamofireImage.xcodeproj` in the Project Navigator and verify the deployment target matches that of your application target.\n- Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the \"Targets\" heading in the sidebar.\n- In the tab bar at the top of that window, open the \"General\" panel.\n- Click on the `+` button under the \"Embedded Binaries\" section.\n- You will see two different `AlamofireImage.xcodeproj` folders each with two different versions of the `AlamofireImage.framework` nested inside a `Products` folder.\n\n  > It does not matter which `Products` folder you choose from, but it does matter whether you choose the top or bottom `AlamofireImage.framework`.\n\n- Select the top `AlamofireImage.framework` for iOS and the bottom one for OS X.\n\n  > You can verify which one you selected by inspecting the build log for your project. The build target for `AlamofireImage` will be listed as either `AlamofireImage iOS`, `AlamofireImage macOS`, `AlamofireImage tvOS` or `AlamofireImage watchOS`.\n\n- And that's it!\n\n  > The `AlamofireImage.framework` is automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.\n\n---\n\n## Usage\n\n### Image Response Serializers\n\n```swift\nimport Alamofire\nimport AlamofireImage\n\nAF.request(\"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fpng\").responseImage { response in\n  debugPrint(response)\n\n  print(response.request)\n  print(response.response)\n  debugPrint(response.result)\n\n  if case .success(let image) = response.result {\n    print(\"image downloaded: \\(image)\")\n  }\n}\n```\n\nThe AlamofireImage response image serializers support a wide range of image types including:\n\n- `application\u002Foctet-stream` - As a fallback for things like AWS which provide no real type.\n- `image\u002Favif` - On 2022 OS versions and later, except watchOS.\n- `image\u002Fbmp`\n- `image\u002Fgif`\n- `image\u002Fheic`, `image\u002Fheif` - On 2017 OS versions and later.\n- `image\u002Fico`\n- `image\u002Fjp2`\n- `image\u002Fjpeg`\n- `image\u002Fjpg`\n- `image\u002Fjxl` - On 2023 OS versions and later.\n- `image\u002Fpng`\n- `image\u002Ftiff`\n- `image\u002Fwebp` - On 2020 OS versions and later, except tvOS and watchOS.\n- `image\u002Fx-bmp`\n- `image\u002Fx-icon`\n- `image\u002Fx-ms-bmp`\n- `image\u002Fx-win-bitmap`\n- `image\u002Fx-xbitmap`\n\n> If the image you are attempting to download is an invalid MIME type not in the list, you can add custom acceptable content types using the `addAcceptableImageContentTypes` extension on the `DataRequest` type.\n\n### UIImage Extensions\n\nThere are several `UIImage` extensions designed to make the common image manipulation operations as simple as possible.\n\n#### Inflation\n\n```swift\nlet url = Bundle.main.url(forResource: \"unicorn\", withExtension: \"png\")!\nlet data = try! Data(contentsOf: url)\nlet image = UIImage(data: data, scale: UIScreen.main.scale)!\n\nimage.af.inflate()\n```\n\n> Inflating compressed image formats (such as PNG or JPEG) in a background queue can significantly improve drawing performance on the main thread.\n\n#### Scaling\n\n```swift\nlet image = UIImage(named: \"unicorn\")!\nlet size = CGSize(width: 100.0, height: 100.0)\n\n\u002F\u002F Scale image to size disregarding aspect ratio\nlet scaledImage = image.af.imageScaled(to: size)\n\n\u002F\u002F Scale image to fit within specified size while maintaining aspect ratio\nlet aspectScaledToFitImage = image.af.imageAspectScaled(toFit: size)\n\n\u002F\u002F Scale image to fill specified size while maintaining aspect ratio\nlet aspectScaledToFillImage = image.af.imageAspectScaled(toFill: size)\n```\n\n#### Rounded Corners\n\n```swift\nlet image = UIImage(named: \"unicorn\")!\nlet radius: CGFloat = 20.0\n\nlet roundedImage = image.af.imageRounded(withCornerRadius: radius)\nlet circularImage = image.af.imageRoundedIntoCircle()\n```\n\n#### Core Image Filters\n\n```swift\nlet image = UIImage(named: \"unicorn\")!\n\nlet sepiaImage = image.af.imageFiltered(withCoreImageFilter: \"CISepiaTone\")\n\nlet blurredImage = image.af.imageFiltered(\n    withCoreImageFilter: \"CIGaussianBlur\",\n    parameters: [\"inputRadius\": 25]\n)\n```\n\n### Image Filters\n\nThe `ImageFilter` protocol was designed to make it easy to apply a filter operation and cache the result after an image finished downloading. It defines two properties to facilitate this functionality.\n\n```swift\npublic protocol ImageFilter {\n    var filter: (Image) -> Image { get }\n    var identifier: String { get }\n}\n```\n\nThe `filter` closure contains the operation used to create a modified version of the specified image. The `identifier` property is a string used to uniquely identify the filter operation. This is useful when adding filtered versions of an image to a cache. All identifier properties inside AlamofireImage are implemented using protocol extensions.\n\n#### Single Pass\n\nThe single pass image filters only perform a single operation on the specified image.\n\n```swift\nlet image = UIImage(named: \"unicorn\")!\nlet imageFilter = RoundedCornersFilter(radius: 10.0)\n\nlet roundedImage = imageFilter.filter(image)\n```\n\nThe current list of single pass image filters includes:\n\n- `ScaledToSizeFilter` - Scales an image to a specified size.\n- `AspectScaledToFitSizeFilter` - Scales an image from the center while maintaining the aspect ratio to fit within a specified size.\n- `AspectScaledToFillSizeFilter` - Scales an image from the center while maintaining the aspect ratio to fill a specified size. Any pixels that fall outside the specified size are clipped.\n- `RoundedCornersFilter` - Rounds the corners of an image to the specified radius.\n- `CircleFilter` - Rounds the corners of an image into a circle.\n- `BlurFilter` - Blurs an image using a `CIGaussianBlur` filter with the specified blur radius.\n\n> Each image filter is built on top of the `UIImage` extensions.\n\n#### Multi-Pass\n\nThe multi-pass image filters perform multiple operations on the specified image.\n\n```swift\nlet image = UIImage(named: \"avatar\")!\nlet size = CGSize(width: 100.0, height: 100.0)\nlet imageFilter = AspectScaledToFillSizeCircleFilter(size: size)\n\nlet avatarImage = imageFilter.filter(image)\n```\n\nThe current list of multi-pass image filters includes:\n\n- `ScaledToSizeWithRoundedCornersFilter` - Scales an image to a specified size, then rounds the corners to the specified radius.\n- `AspectScaledToFillSizeWithRoundedCornersFilter` - Scales an image from the center while maintaining the aspect ratio to fit within a specified size, then rounds the corners to the specified radius.\n- `ScaledToSizeCircleFilter` - Scales an image to a specified size, then rounds the corners into a circle.\n- `AspectScaledToFillSizeCircleFilter` - Scales an image from the center while maintaining the aspect ratio to fit within a specified size, then rounds the corners into a circle.\n\n### Image Cache\n\nImage caching can become complicated when it comes to network images. `URLCache` is quite powerful and does a great job reasoning through the various cache policies and `Cache-Control` headers. However, it is not equipped to handle caching multiple modified versions of those images.\n\nFor example, let's say you need to download an album of images. Your app needs to display both the thumbnail version as well as the full size version at various times. Due to performance issues, you want to scale down the thumbnails to a reasonable size before rendering them on-screen. You also need to apply a global CoreImage filter to the full size images when displayed. While `URLCache` can easily handle storing the original downloaded image, it cannot store these different variants. What you really need is another caching layer designed to handle these different variants.\n\n```swift\nlet imageCache = AutoPurgingImageCache(\n    memoryCapacity: 100_000_000,\n    preferredMemoryUsageAfterPurge: 60_000_000\n)\n```\n\nThe `AutoPurgingImageCache` in AlamofireImage fills the role of that additional caching layer. It is an in-memory image cache used to store images up to a given memory capacity. When the memory capacity is reached, the image cache is sorted by last access date, then the oldest image is continuously purged until the preferred memory usage after purge is met. Each time an image is accessed through the cache, the internal access date of the image is updated.\n\n#### Add \u002F Remove \u002F Fetch Images\n\nInteracting with the `ImageCache` protocol APIs is very straightforward.\n\n```swift\nlet imageCache = AutoPurgingImageCache()\nlet avatarImage = UIImage(data: data)!\n\n\u002F\u002F Add\nimageCache.add(avatarImage, withIdentifier: \"avatar\")\n\n\u002F\u002F Fetch\nlet cachedAvatar = imageCache.image(withIdentifier: \"avatar\")\n\n\u002F\u002F Remove\nimageCache.removeImage(withIdentifier: \"avatar\")\n```\n\n#### URL Requests\n\nThe `ImageRequestCache` protocol extends the `ImageCache` protocol by adding support for `URLRequest` caching. This allows a `URLRequest` and an additional identifier to generate the unique identifier for the image in the cache.\n\n```swift\nlet imageCache = AutoPurgingImageCache()\n\nlet urlRequest = URLRequest(url: URL(string: \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fpng\")!)\nlet avatarImage = UIImage(named: \"avatar\")!.af.imageRoundedIntoCircle()\n\n\u002F\u002F Add\nimageCache.add(avatarImage, for: urlRequest, withIdentifier: \"circle\")\n\n\u002F\u002F Fetch\nlet cachedAvatarImage = imageCache.image(for: urlRequest, withIdentifier: \"circle\")\n\n\u002F\u002F Remove\nimageCache.removeImage(for: urlRequest, withIdentifier: \"circle\")\n```\n\n#### Auto-Purging\n\nEach time an image is fetched from the cache, the cache internally updates the last access date for that image.\n\n```swift\nlet avatar = imageCache.image(withIdentifier: \"avatar\")\nlet circularAvatar = imageCache.image(for: urlRequest, withIdentifier: \"circle\")\n```\n\nBy updating the last access date for each image, the image cache can make more informed decisions about which images to purge when the memory capacity is reached. The `AutoPurgingImageCache` automatically evicts images from the cache in order from oldest last access date to newest until the memory capacity drops below the `preferredMemoryUsageAfterPurge`.\n\n> It is important to set reasonable default values for the `memoryCapacity` and `preferredMemoryCapacityAfterPurge` when you are initializing your image cache. By default, the `memoryCapacity` equals 100 MB and the `preferredMemoryCapacityAfterPurge` equals 60 MB.\n\n#### Memory Warnings\n\nThe `AutoPurgingImageCache` also listens for memory warnings from your application and will purge all images from the cache if a memory warning is observed.\n\n### Image Downloader\n\nThe `ImageDownloader` class is responsible for downloading images in parallel on a prioritized queue. It uses an internal Alamofire `Session` instance to handle all the downloading and response image serialization. By default, the initialization of an `ImageDownloader` uses a default `URLSessionConfiguration` with the most common parameter values.\n\n```swift\nlet imageDownloader = ImageDownloader(\n    configuration: ImageDownloader.defaultURLSessionConfiguration(),\n    downloadPrioritization: .fifo,\n    maximumActiveDownloads: 4,\n    imageCache: AutoPurgingImageCache()\n)\n```\n\n> If you need to customize the `URLSessionConfiguration` type or parameters, then simply provide your own rather than using the default.\n\n#### Downloading an Image\n\n```swift\nlet downloader = ImageDownloader()\nlet urlRequest = URLRequest(url: URL(string: \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fjpeg\")!)\n\ndownloader.download(urlRequest) { response in\n    print(response.request)\n    print(response.response)\n    debugPrint(response.result)\n\n    if case .success(let image) = response.result {\n        print(image)\n    }\n}\n```\n\n> Make sure to keep a strong reference to the `ImageDownloader` instance, otherwise the `completion` closure will not be called because the `downloader` reference will go out of scope before the `completion` closure can be called.\n\n#### Applying an ImageFilter\n\n```swift\nlet downloader = ImageDownloader()\nlet urlRequest = URLRequest(url: URL(string: \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fjpeg\")!)\nlet filter = AspectScaledToFillSizeCircleFilter(size: CGSize(width: 100.0, height: 100.0))\n\ndownloader.download(urlRequest, filter: filter) { response in\n    print(response.request)\n    print(response.response)\n    debugPrint(response.result)\n\n    if case .success(let image) = response.result {\n        print(image)\n    }\n}\n```\n\n#### Authentication\n\nIf your images are behind HTTP Basic Auth, you can append the `user:password:` or the `credential` to the `ImageDownloader` instance. The credentials will be applied to all future download requests.\n\n```swift\nlet downloader = ImageDownloader()\ndownloader.addAuthentication(user: \"username\", password: \"password\")\n```\n\n#### Download Prioritization\n\nThe `ImageDownloader` maintains an internal queue of pending download requests. Depending on your situation, you may want incoming downloads to be inserted at the front or the back of the queue. The `DownloadPrioritization` enumeration allows you to specify which behavior you would prefer.\n\n```swift\npublic enum DownloadPrioritization {\n    case fifo, lifo\n}\n```\n\n> The `ImageDownloader` is initialized with a `.fifo` queue by default.\n\n#### Image Caching\n\nThe `ImageDownloader` uses a combination of an `URLCache` and `AutoPurgingImageCache` to create a very robust, high performance image caching system.\n\n##### URLCache\n\nThe `URLCache` is used to cache all the original image content downloaded from the server. By default, it is initialized with a memory capacity of 20 MB and a disk capacity of 150 MB. This allows up to 150 MB of original image data to be stored on disk at any given time. While these defaults have been carefully set, it is very important to consider your application's needs and performance requirements and whether these values are right for you.\n\n> If you wish to disable this caching layer, create a custom `URLSessionConfiguration` with the `urlCache` property set to `nil` and use that configuration when initializing the `ImageDownloader`.\n\n##### Image Cache\n\nThe `ImageCache` is used to cache all the potentially filtered image content after it has been downloaded from the server. This allows multiple variants of the same image to also be cached, rather than having to re-apply the image filters to the original image each time it is required. By default, an `AutoPurgingImageCache` is initialized with a memory capacity of 100 MB and a preferred memory usage after purge limit of 60 MB. This allows up to 100 MB of most recently accessed filtered image content to be stored in-memory at a given time.\n\n##### Setting Ideal Capacity Limits\n\nDetermining the ideal the in-memory and on-disk capacity limits of the `URLCache` and `AutoPurgingImageCache` requires a bit of forethought. You must carefully consider your application's needs, and tailor the limits accordingly. By default, the combination of caches offers the following storage capacities:\n\n- 150 MB of on-disk storage (original image only)\n- 20 MB of in-memory original image data storage (original image only)\n- 100 MB of in-memory storage of filtered image content (filtered image if using filters, otherwise original image)\n- 60 MB preferred memory capacity after purge of filtered image content\n\n> If you do not use image filters, it is advised to set the memory capacity of the `URLCache` to zero. Otherwise, you will be storing the original image data in both the URLCache's in-memory store as well as the AlamofireImage in-memory store.\n\n#### Duplicate Downloads\n\nSometimes application logic can end up attempting to download an image more than once before the initial download request is complete. Most often, this results in the image being downloaded more than once. AlamofireImage handles this case elegantly by merging the duplicate downloads. The image will only be downloaded once, yet both completion handlers will be called.\n\n##### Image Filter Reuse\n\nIn addition to merging duplicate downloads, AlamofireImage can also merge duplicate image filters. If two image filters with the same identifier are attached to the same download, the image filter is only executed once and both completion handlers are called with the same resulting image. This can save large amounts of time and resources for computationally expensive filters such as ones leveraging CoreImage.\n\n##### Request Receipts\n\nSometimes it is necessary to cancel an image download for various reasons. AlamofireImage can intelligently handle cancellation logic in the `ImageDownloader` by leveraging the `RequestReceipt` type along with the `cancelRequestForRequestReceipt` method. Each download request vends a `RequestReceipt` which can be later used to cancel the request.\n\nBy cancelling the request through the `ImageDownloader` using the `RequestReceipt`, AlamofireImage is able to determine how to best handle the cancellation. The cancelled download will always receive a cancellation error, while duplicate downloads are allowed to complete. If the download is already active, it is allowed to complete even though the completion handler will be called with a cancellation error. This greatly improves performance of table and collection views displaying large amounts of images.\n\n> It is NOT recommended to directly call `cancel` on the `request` in the `RequestReceipt`. Doing so can lead to issues such as duplicate downloads never being allowed to complete.\n\n### UIImageView Extension\n\nThe [UIImage Extensions](#uiimage-extensions), [Image Filters](#image-filters), [Image Cache](#image-cache) and [Image Downloader](#image-downloader) were all designed to be flexible and standalone, yet also to provide the foundation of the `UIImageView` extension. Due to the powerful support of these classes, protocols and extensions, the `UIImageView` APIs are concise, easy to use and contain a large amount of functionality.\n\n#### Setting Image with URL\n\nSetting the image with a URL will asynchronously download the image and set it once the request is finished.\n\n```swift\nlet imageView = UIImageView(frame: frame)\nlet url = URL(string: \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fpng\")!\n\nimageView.af.setImage(withURL: url)\n```\n\n> If the image is cached locally, the image is set immediately.\n\n#### Placeholder Images\n\nBy specifying a placeholder image, the image view uses the placeholder image until the remote image is downloaded.\n\n```swift\nlet imageView = UIImageView(frame: frame)\nlet url = URL(string: \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fpng\")!\nlet placeholderImage = UIImage(named: \"placeholder\")!\n\nimageView.af.setImage(withURL: url, placeholderImage: placeholderImage)\n```\n\n> If the remote image is cached locally, the placeholder image is never set.\n\n#### Image Filters\n\nIf an image filter is specified, it is applied asynchronously after the remote image is downloaded. Once the filter execution is complete, the resulting image is set on the image view.\n\n```swift\nlet imageView = UIImageView(frame: frame)\n\nlet url = URL(string: \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fpng\")!\nlet placeholderImage = UIImage(named: \"placeholder\")!\n\nlet filter = AspectScaledToFillSizeWithRoundedCornersFilter(\n    size: imageView.frame.size,\n    radius: 20.0\n)\n\nimageView.af.setImage(\n    withURL: url,\n    placeholderImage: placeholderImage,\n    filter: filter\n)\n```\n\n> If the remote image with the applied filter is cached locally, the image is set immediately.\n\n#### Image Transitions\n\nBy default, there is no image transition animation when setting the image on the image view. If you wish to add a cross dissolve or flip-from-bottom animation, then specify an `ImageTransition` with the preferred duration.\n\n```swift\nlet imageView = UIImageView(frame: frame)\n\nlet url = URL(string: \"https:\u002F\u002Fhttpbin.org\u002Fimage\u002Fpng\")!\nlet placeholderImage = UIImage(named: \"placeholder\")!\n\nlet filter = AspectScaledToFillSizeWithRoundedCornersFilter(\n    size: imageView.frame.size,\n    radius: 20.0\n)\n\nimageView.af.setImage(\n    withURL: url,\n    placeholderImage: placeholderImage,\n    filter: filter,\n    imageTransition: .crossDissolve(0.2)\n)\n```\n\n> If the remote image is cached locally, the image transition is ignored.\n\n#### Image Downloader\n\nThe `UIImageView` extension is powered by the default `ImageDownloader` instance. To customize cache capacities, download priorities, request cache policies, timeout durations, etc., please refer to the [Image Downloader](#image-downloader) documentation.\n\n##### Authentication\n\nIf an image requires and authentication credential from the `UIImageView` extension, it can be provided as follows:\n\n```swift\nImageDownloader.default.addAuthentication(user: \"user\", password: \"password\")\n```\n\n---\n\n## Credits\n\nAlamofire is owned and maintained by the [Alamofire Software Foundation](http:\u002F\u002Falamofire.org).\n\n### Security Disclosure\n\nIf you believe you have identified a security vulnerability with AlamofireImage, you should report it as soon as possible via email to security@alamofire.org. Please do not post it to a public issue tracker.\n\n## Donations\n\nThe [ASF](https:\u002F\u002Fgithub.com\u002FAlamofire\u002FFoundation#members) is looking to raise money to officially stay registered as a federal non-profit organization.\nRegistering will allow us members to gain some legal protections and also allow us to put donations to use, tax free.\nDonating to the ASF will enable us to:\n\n- Pay our yearly legal fees to keep the non-profit in good status\n- Pay for our mail servers to help us stay on top of all questions and security issues\n- Potentially fund test servers to make it easier for us to test the edge cases\n- Potentially fund developers to work on one of our projects full-time\n\nThe community adoption of the ASF libraries has been amazing.\nWe are greatly humbled by your enthusiasm around the projects, and want to continue to do everything we can to move the needle forward.\nWith your continued support, the ASF will be able to improve its reach and also provide better legal safety for the core members.\nIf you use any of our libraries for work, see if your employers would be interested in donating.\nAny amount you can donate today to help us reach our goal would be greatly appreciated.\n\n[![paypal](https:\u002F\u002Fwww.paypalobjects.com\u002Fen_US\u002Fi\u002Fbtn\u002Fbtn_donateCC_LG.gif)](https:\u002F\u002Fwww.paypal.com\u002Fcgi-bin\u002Fwebscr?cmd=_s-xclick&hosted_button_id=W34WPEE74APJQ)\n\n## License\n\nAlamofireImage is released under the MIT license. [See LICENSE](https:\u002F\u002Fgithub.com\u002FAlamofire\u002FAlamofireImage\u002Fblob\u002Fmaster\u002FLICENSE) for details.\n","AlamofireImage 是一个为 Alamofire 设计的图像组件库。它提供了丰富的功能，包括图像响应序列化、UIImage 扩展（如膨胀、缩放、圆角处理和 CoreImage 支持）、单次和多次图像滤镜、自动清理内存中的图像缓存、优先级队列顺序下载图像等。此外，它还支持带有占位符的异步远程下载到 UIImageView 以及图像过滤器和过渡效果。AlamofireImage 适用于需要高效处理网络图片的应用场景，尤其适合 iOS、macOS、tvOS、watchOS 和 visionOS 平台上使用 Swift 开发的项目。",2,"2026-06-11 03:09:31","top_language"]